How do you clean up an effect in useEffect?
useEffect and Side Effects
Audio flashcard · 0:11Nortren·
How do you clean up an effect in useEffect?
0:11
You return a cleanup function from the effect. React calls this function before the next effect runs and when the component unmounts. It is commonly used to remove event listeners, cancel timers, or close subscriptions.