ReReact · Lesson 4 of 8
useEffect & Side Effects
`useEffect` is where you handle things that happen outside the React render cycle: API calls, timers, subscriptions, DOM manipulation. It runs after every render, unless you tell it otherwise.
✦ Tip
Always return a cleanup function from useEffect if you start something (timer, subscription, event listener, fetch). Without cleanup, you get memory leaks and "Can't perform state update on unmounted component" warnings. The `cancelled` flag pattern is especially important for fetch calls.
Always return a cleanup function from useEffect if you start something (timer, subscription, event listener, fetch). Without cleanup, you get memory leaks and "Can't perform state update on unmounted component" warnings. The `cancelled` flag pattern is especially important for fetch calls.