Skip to content

Fix useMemo deps growing between renders in SearchConditions (#94) - #96

Open
reekitconcept wants to merge 1 commit into
mainfrom
kid/fix-searchconditions-deps-main
Open

Fix useMemo deps growing between renders in SearchConditions (#94)#96
reekitconcept wants to merge 1 commit into
mainfrom
kid/fix-searchconditions-deps-main

Conversation

@reekitconcept

Copy link
Copy Markdown
Member

Fixes the React dev warning The final argument passed to useMemo changed size between renders on the search page. Fixes #94.

The deps array spread Object.values(vocabData), which grows from 0 to N entries as facet vocabularies load. vocabData comes from useSelector(..., shallowEqual) in useVocabs, so its identity already changes exactly when some vocabulary's items change — it serves as a single constant-size dependency with identical recompute triggers (no missed updates, no per-render recomputes; react-redux reuses the previous reference when the equality function passes, in both v7 and v8 semantics).

Cherry-pick of the fix from the feature-ai-rag line (#95); verified there in the browser (warning gone) and by the 17 SearchConditions unit tests.

React warned 'The final argument passed to useMemo changed size between
renders': the deps array spread Object.values(vocabData), which grows
from 0 to N entries as vocabularies load. vocabData comes from
useSelector(..., shallowEqual) in useVocabs, so its identity already
changes exactly when some vocabulary's items change - use the object
itself as a constant-size dependency.
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.

React warning: useMemo deps array changes size in SearchConditions

1 participant