Interview practice question
Warning about updating state on an unmounted component or leaking subscriptions
Frontend Engineering · React · Intermediate
Users navigate away from a page, but its interval and WebSocket keep running and cause errors. How do you fix this?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Effects must return cleanup.
- clearInterval, close socket, remove listeners.
- Abort pending fetches.
- StrictMode helps reveal missing cleanup.
- Encapsulate in custom hooks.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.