Tech
Why Your React useEffect Cleanup Function Isn't Running (The Dependency Array Gotcha)
Why Your React useEffect Cleanup Function Isn't Running (The Dependency Array Gotcha)
You add a cleanup function to your useEffect . You expect it to run when the component unmounts, or when a dependency changes before the effect re-runs. You test it. Nothing happens. No console log, no unsubscribe, no cleared interval — just silence, and a bug report from a user seeing duplicate event listeners or a memory leak that grows worse the longer they use your app.
If you've hit this, you're no...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to