Skip to content

Commit

Permalink
Fix warning about unsync state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Dec 16, 2022
1 parent ff39593 commit df68d01
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions searchlib/components/SearchApp/useSearchApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import { loadingFamily, driverFamily } from './state';
function useSearchDriver({ elasticConfig, appName }) {
const driverAtom = driverFamily({ elasticConfig, appName });
const driver = useAtomValue(driverAtom);

React.useEffect(() => {
return () => driver.tearDown();
}, [driver]);

return driver;
}

Expand Down Expand Up @@ -78,8 +83,6 @@ function useSearchApp({
? { filters: getDefaultFilters(appConfig) }
: {}),
},
// trackUrlState: false,
// debug: true,
}),
[appConfig, onAutocomplete, onSearch, locationSearchTerm],
);
Expand Down
6 changes: 1 addition & 5 deletions searchlib/components/SearchView/SearchView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export const SearchView = (props) => {
const { driver } = React.useContext(SUISearchContext);
const [, setIsLandingPageAtom] = useAtom(isLandingPageAtom);

const layoutComponent =
appConfig.layoutVariation === 'full'
? appConfig.layoutComponent
: appConfig.layoutComponent; // layoutVariation
const Layout = registry.resolve[layoutComponent].component;
const Layout = registry.resolve[appConfig.layoutComponent].component;

const searchedTerm = driver.URLManager.getStateFromURL().searchTerm;

Expand Down
1 change: 1 addition & 0 deletions searchlib/lib/hocs/useProxiedSearchContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function useProxiedSearchContext(
driver[name] = wrapper[func_name];
});
setDriver(driver);
return () => driver.tearDown();
}, [searchContext, setDriver, searchContextId]); // dirtyFilters, setDirtyFilters

const applySearch = React.useCallback(() => {
Expand Down
4 changes: 4 additions & 0 deletions searchlib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ const config = {
headline: '', // main headline
subheadline: '', // text under the headline
demoquestion: '', // Question used as example under the search input

// These are ElasticSearch driver options:
// debug: true,
// trackUrlState: false,

hasA11yNotifications: true,

// broad global layout (header, side, etc)
Expand Down

0 comments on commit df68d01

Please sign in to comment.