Add missing useEffect cleanup functions to prevent memory leaks
- Dominant language
- Python
- Stars
- 451
- Forks
- 707
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 91
Description
## Describe the bug
Some React components and hooks register side effects inside `useEffect` (such as event listeners, timers, or async operations) without returning cleanup functions.
This can lead to memory leaks or unexpected behavior when components unmount or when effects re-run due to dependency changes.
## To Reproduce
Steps to reproduce the behavior:
1. Navigate to pages that use the affected components (e.g. search or map-related views).
2. Interact with the page (search, navigation, map interactions).
3. Navigate away from the page or trigger re-renders.
4. Observe that side effects may remain active after unmount (e.g. duplicated listeners, stale state updates).
## Expected behavior
All `useEffect` hooks that register side effects should return appropriate cleanup functions so that resources are released correctly when components unmount or dependencies change.
## Are you going to work on fixing this?
- [x] Yes
- [ ] No
## Screenshots
Not applicable.
## Desktop (please complete the following information):
- OS: Any
- Browser: Any modern browser
- Version: N/A
## Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
## Additional context
Affected files include:
- `ChapterMap.tsx`
- `MultiSearch.tsx`
- `useSearchPage.ts`
Adding cleanup functions (e.g. removing event listeners, clearing timers, aborting async operations) will align these components with React best practices and prevent potential memory leaks.
Contributor guide
Assessment
This issue has not been assessed yet.