React · Junior · Question 25 of 75

When does an effect without a dependency array run: useEffect(() => { ... })?

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).

Further reading

Problem with a question

React · Junior · question 25

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz