perform search on first navigate
Signed-off-by: John Philip <jphilip@spotify.com>
This commit is contained in:
@@ -138,14 +138,13 @@ const useSearchContextValue = (
|
||||
|
||||
const result = useAsync(async (): Promise<SearchResultSet> => {
|
||||
if (isFirstEmptyMount.current) {
|
||||
isFirstEmptyMount.current = false;
|
||||
if (!term && !types.length && !Object.keys(filters).length) {
|
||||
return {
|
||||
results: [],
|
||||
numberOfResults: 0,
|
||||
};
|
||||
}
|
||||
|
||||
isFirstEmptyMount.current = false;
|
||||
}
|
||||
|
||||
// Here we cancel the previous request before making a new one
|
||||
|
||||
@@ -59,9 +59,7 @@ export const UrlUpdater = () => {
|
||||
setPageCursor(query.pageCursor as string);
|
||||
}
|
||||
|
||||
if (query.types) {
|
||||
setTypes(query.types as string[]);
|
||||
}
|
||||
setTypes(query.types ? (query.types as string[]) : []);
|
||||
}, [prevQueryParams, location, setTerm, setTypes, setPageCursor, setFilters]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user