fix: prevent unnecessary refinement when subpathname is empty #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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