diff --git a/frontend/packages/volto-solr/news/94.bugfix b/frontend/packages/volto-solr/news/94.bugfix new file mode 100644 index 00000000..61f41c4a --- /dev/null +++ b/frontend/packages/volto-solr/news/94.bugfix @@ -0,0 +1 @@ +Fix React warning in SearchConditions: the useMemo dependency array grew as vocabularies loaded (spread of vocabData values); use the vocabData object itself as a constant-size dependency. @reebalazs diff --git a/frontend/packages/volto-solr/src/components/theme/SolrSearch/SearchConditions.jsx b/frontend/packages/volto-solr/src/components/theme/SolrSearch/SearchConditions.jsx index b13e1dcb..5026796f 100644 --- a/frontend/packages/volto-solr/src/components/theme/SolrSearch/SearchConditions.jsx +++ b/frontend/packages/volto-solr/src/components/theme/SolrSearch/SearchConditions.jsx @@ -147,8 +147,12 @@ export const SearchConditions = ({ })} ) : null, - // Use spread operator to perform a shallow equality check on the vocabData object + // vocabData comes from useSelector(..., shallowEqual) in useVocabs, + // so its identity only changes when some vocabulary's items change: + // it works as a single dependency. (Spreading its values here made + // the deps array grow as vocabularies loaded, which React warns + // about: the deps array size must stay constant between renders.) // eslint-disable-next-line react-hooks/exhaustive-deps - [JSON.stringify(facetFields), conditionTree, ...Object.values(vocabData)], + [JSON.stringify(facetFields), conditionTree, vocabData], ); };