Skip to content

Conversation

@Riddhish1
Copy link
Owner

Fix: Resolve infinite loop in search modal causing page freeze
Problem
When searching in the documentation search modal (e.g., searching for "sitemap" on /start/latest), the page would become unresponsive and freeze due to an infinite render loop.

Root Cause
The LibraryRefinement and FrameworkRefinement components had items and refine in their useEffect dependency arrays. This caused:

Search query updates → items array changes
useEffect runs → calls refine()
refine() triggers re-render → items array changes again
Loop continues indefinitely → page freezes
Solution
Removed items and refine from useEffect dependency arrays in both refinement components
Changed dependencies to only trigger on route changes (subpathname)
Added items.length > 0 check to ensure refinement only happens when items are available
Added ESLint disable comment for exhaustive-deps where appropriate
Testing
✅ Search functionality works without freezing
✅ Library and framework filters still auto-apply based on current route
✅ No infinite loops or performance issues
✅ Search results display correctly
Files Changed
SearchModal.tsx

@Riddhish1 Riddhish1 merged commit c0963f9 into main Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants