useEffect Hook Flashcards
6 cards from real React practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 useEffect Hook flashcards as text
What does React do when a dependency in useEffect's array changes?
Answer: Runs the cleanup of the previous effect, then re-runs the new effect
React calls the previous effect's cleanup function before re-running the effect with the new dependency values.
In React StrictMode (development), how many times does a useEffect fire on mount?
Answer: Twice (mount, unmount, remount) to detect side-effect issues
StrictMode intentionally double-invokes effects to help detect missing cleanup logic.
What does the eslint-plugin-react-hooks exhaustive-deps rule enforce?
Answer: All values referenced inside the effect must be listed in the dependency array
The exhaustive-deps rule warns when you use a value inside useEffect without listing it as a dependency.
Which situation would cause an infinite loop with useEffect?
Answer: Updating state inside the effect that is also a dependency of the same effect
If you update state that is also listed as a dependency, the effect fires → updates state → fires again endlessly.
How should you add an event listener and clean it up with useEffect?
Answer: Add in useEffect and return a function that removes the listener
Returning a cleanup function that calls removeEventListener ensures no listener leak when the component unmounts.
What is the correct term for a function defined inside useEffect that is used as a callback?
Answer: Effect closure
Functions inside useEffect form closures over the values present at the time the effect ran.
Written and edited by Nathan Beja, founder of Practice Test Geeks, with AI assistance. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Editorial policy