Problem Statement
What is the purpose of the useEffect hook?
Explanation
useEffect runs after the component renders and is used for effects like fetching data, setting timers, or subscribing to events.
You can also return a cleanup function to remove listeners when the component unmounts.
Code Solution
SolutionRead Only
useEffect(() => { fetchData(); return () => cleanup(); }, []);