React Dojo

Search

Search concepts, exercises and quizzes

Quiz

Effects

10 questions

useEffect: when it runs, cleanup, dependencies, and common mistakes

01When does useEffect without a dependency array (no second argument) run?
02What is the function returned by useEffect (the cleanup function) for?
03Why can't you mark the useEffect function directly as async?
04What happens if you update state inside useEffect with [] as dependencies?
05How many times does useEffect with [] run in React.StrictMode in development?
06What is a 'stale closure' in the context of useEffect?
07When does the cleanup of a useEffect with [userId] dependencies run?
08Is it correct to have multiple useEffect calls in the same component?
09What problem arises from including an object created in the render as a useEffect dependency?
10What is the correct way to fetch data inside useEffect?
Was this helpful?
Sign in to give feedback