Difficulty: 5/10useEffect cleanup, resource management, memory leaks1Cancel network requests.2Clear timeouts3Clear intervals4Remove event listeners5Close WebSockets.Scenario Questions0-2 years experience1You have a functional component that starts a setInterval inside useEffect. How do you make sure the interval stops when the component unmounts?2If you add a window resize listener in a component, what do you need to do in the cleanup function to avoid issues?3What would happen if you forget to return a cleanup function from a useEffect that opens a WebSocket connection?Follow-up QuestionsWhat kinds of bugs typically surface when a cleanup is omitted?How does the timing of the cleanup affect user experience or performance?Can you think of a situation where you would conditionally skip a cleanup step?Suggest Improvement