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 is the primary purpose of the useEffect hook?
Answer: To perform side effects in function components
useEffect lets you synchronize a component with external systems by running side effects after render.
When does a useEffect with an empty dependency array [] run?
Answer: Only once after the initial render
An empty dependency array tells React to run the effect only once, after the first render.
What does the cleanup function returned from useEffect do?
Answer: Runs before the next effect or on unmount to cancel subscriptions
The cleanup function runs before the effect re-fires and on component unmount to avoid memory leaks.
What happens when you omit the dependency array from useEffect?
Answer: The effect runs after every render
Without a dependency array, useEffect runs after every completed render.
Which of the following is a valid useEffect cleanup?
Answer: useEffect(() => { return () => clearInterval(id); })
The cleanup must be a function returned from the effect callback, not the direct result of clearInterval.
In which phase does useEffect run relative to the browser paint?
Answer: After the browser has painted
useEffect is deferred and runs asynchronously after the browser has painted the screen.
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