website
website copied to clipboard
Fix Event Listener Memory Leak in AlgoliaSearch Component
Description The AlgoliaSearch component in pages/index.page.tsx attaches an event listener in useEffect but does not remove it on unmount, causing a memory leak and potential duplicate event handlers on re-renders or hot reloads.
Problems
- No cleanup using removeEventListener
- May cause multiple triggers during development (Fast Refresh)
Proposed Fix
- Add a named function and return a cleanup function:
- Prevents memory leaks
- Avoids duplicate clicks in development
- Matches best practices for event listeners in React
- Keeps the component stable across re-renders and theme changes
@Utkarsh-123github Can I work on this issue ?
hey @Utkarsh-123github I am aiming for Gsoc 2026 & I'd like to contribute to this project