Problem
The LiveTicker component is causing a silent memory leak due to duplicated event listeners (such as window.resize).
Each time the Live Ticker is toggled on and off, a new event listener is attached without removing the previous one, causing memory usage to grow and the app to slow down over time.
Points: 30
Steps to Reproduce
- Open the application and navigate to the Live Ticker section.
- Toggle the Live Ticker on and off repeatedly.
- Use browser dev tools (Performance tab or
getEventListeners(window)) to inspect listeners.
- Notice:
- The number of attached event listeners keeps increasing.
- Performance degrades as more listeners accumulate.
- Listeners are never removed on unmount or re-render.
Expected Behavior
The component should:
- Attach event listeners only once, or only when necessary.
- Properly clean up all listeners in the
useEffect cleanup function.
- Avoid re-attaching listeners on every render or toggle.
Proper example pattern:
useEffect(() => {
const handleResize = () => { ... };
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, []);
Problem
The LiveTicker component is causing a silent memory leak due to duplicated event listeners (such as
window.resize).Each time the Live Ticker is toggled on and off, a new event listener is attached without removing the previous one, causing memory usage to grow and the app to slow down over time.
Points: 30
Steps to Reproduce
getEventListeners(window)) to inspect listeners.Expected Behavior
The component should:
useEffectcleanup function.Proper example pattern: