React · Junior · Question 24 of 75

When does the effect useEffect(() => { ... }, []) run?

Explanation

An empty dependency array means "synchronize after mounting". Effects always run after painting, not before. In development, StrictMode mounts, unmounts and mounts the component again to verify that the effect's cleanup is written correctly.

Further reading

Problem with a question

React · Junior · question 24

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