1. Home
  2. Computer Science MCQs
  3. REACT
  4. When useEffect is given an empty dependency array ([])…

Added 2 Nov 2026

When useEffect is given an empty dependency array ([]), the effect runs:

  1. Never, because nothing is being watched
  2. Before every render of the component
  3. After every render of the component
  4. Only once, after the first render Correct answer

Correct answer

D. Only once, after the first render

16 views

MCQSEXAM

Explanation

An empty dependency array means nothing can trigger the effect again, so it runs once after mounting. Any cleanup function it returns runs on unmount. This is typical for initial data fetching.

Reference

Asked in: React Interviews, Frontend Developer Tests

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More REACT MCQs

Practise all REACT MCQs

Similar MCQs