Skip to content

Commit

Permalink
Use deepcompare for appcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Jan 6, 2023
1 parent c9ce132 commit 0ce0973
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions searchlib/components/SearchApp/BasicSearchApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { SearchProvider, withSearch } from '@elastic/react-search-ui'; // ErrorBoundary, WithSearch,
import useDeepCompareEffect from 'use-deep-compare-effect';
import { useDeepCompareMemoize } from 'use-deep-compare-effect';

import { AppConfigContext, SearchContext } from '@eeacms/search/lib/hocs';
import { bindOnAutocomplete, bindOnSearch } from '@eeacms/search/lib/request';
Expand Down Expand Up @@ -96,14 +96,16 @@ export default function BasicSearchApp(props) {
mapContextToProps,
]);

const [stableContext, setStableContext] = React.useState({
appConfig,
registry,
});
const stableContext = useDeepCompareMemoize({ appConfig, registry });

useDeepCompareEffect(() => {
setStableContext({ appConfig, registry });
}, [appConfig, registry]);
// const [stableContext, setStableContext] = React.useState({
// appConfig,
// registry,
// });
//
// useDeepCompareEffect(() => {
// setStableContext({ appConfig, registry });
// }, [appConfig, registry]);

const WrappedSearchView = React.useMemo(() => {
return mappedWithSearch(applySearchWrappers(searchViewComponent));
Expand Down

0 comments on commit 0ce0973

Please sign in to comment.