Fix: infinite render loop in documentation search modal #602
+4
−2
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.
Problem
Searching in the documentation search modal (for example, “sitemap” on /start/latest) caused the page to freeze due to an infinite render loop. This behavior is tracked in #601.
Root Cause
The LibraryRefinement and FrameworkRefinement components included items and refine in their useEffect dependency arrays, which caused a feedback loop:
Search query updates → items changes
useEffect runs → calls refine()
refine() triggers a re-render → items changes again
Loop repeats indefinitely, freezing the page
Solution
Removed items and refine from the useEffect dependency arrays
Updated effects to trigger only on route changes (subpathname)
Added an items.length > 0 guard to ensure refinement runs only when data is available
Added an ESLint disable comment for react-hooks/exhaustive-deps where appropriate
Testing
✅ Search works without freezing
✅ Library and framework filters still auto-apply based on the current route
✅ No infinite loops or performance issues
✅ Search results render correctly
Files Changed
SearchModal.tsx