website icon indicating copy to clipboard operation
website copied to clipboard

Fix Event Listener Memory Leak in AlgoliaSearch Component

Open vishwansh01 opened this issue 1 month ago • 2 comments

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.

Image

Problems

  • No cleanup using removeEventListener
  • May cause multiple triggers during development (Fast Refresh)

Proposed Fix

  • Add a named function and return a cleanup function:
Image
  • 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

vishwansh01 avatar Nov 13 '25 07:11 vishwansh01

@Utkarsh-123github Can I work on this issue ?

vishwansh01 avatar Nov 13 '25 07:11 vishwansh01

hey @Utkarsh-123github I am aiming for Gsoc 2026 & I'd like to contribute to this project

shubham220420 avatar Nov 14 '25 14:11 shubham220420