← React Beginner Questions - Set 8 Q77

What is the useEffect hook used for?

React Beginner Questions - Set 8

Example

useEffect(() => {
  const id = setInterval(() => setTick(t => t + 1), 1000);
  return () => clearInterval(id);   // cleanup on unmount
}, []);

What to notice

← Back to the question list