React · Junior · Question 25 of 75
When does an effect without a dependency array run: useEffect(() => { ... })?
- 1Only once - right after the component mounts
- ✓Correct answer: After every render of the component
- 3Never: without a dependency array the effect doesn't run
Explanation
Without the second argument, the effect runs after every render. With [] - only after mounting. With [a, b] - after mounting and whenever a or b changes (compared via Object.is).