When useEffect is given an empty dependency array ([]), the effect runs:
Correct answer
D. Only once, after the first render
16 views
D. Only once, after the first render
16 views
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.
Asked in: React Interviews, Frontend Developer Tests
Not sure why the answer is D? Ask here and get an explanation.