Problem Statement
What are the two types of side effects?
Explanation
There are two types: effects without cleanup (like API calls or logging) and effects with cleanup (like removing event listeners or cancelling timers). useEffect can handle both types using return functions.
Code Solution
SolutionRead Only
useEffect(() => {
const timer = setInterval(() => console.log('tick'), 1000);
return () => clearInterval(timer); // cleanup
}, []);