You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I sync the search state with the url. For example, when I visit /search?query=Algolia, I expect the initial load will have the query "Algolia" and filter the results accordingly. It works perfectly fine.
However, the initial load doesn't include the "query=Algolia" when I try to use the queryHook to debounce the search. Instead, it just sends an empty query.
What would be the issue here and how could I solve that?
import {
SearchBox,
} from "react-instantsearch-hooks-web";
export function Search({ serverState, serverUrl, locale }: SearchProps) {
// Debounce search
const queryHook: SearchBoxProps["queryHook"] = (query, search) => {
search(query);
}
return (
<InstantSearchSSRProvider {...serverState}>
<InstantSearch
searchClient={searchClient}
indexName={searchIndex}
insights
routing={{
router: history({
getLocation() {
if (typeof window === "undefined") {
return new URL(
serverUrl
) as unknown as Location;
}
return window.location;
},
}),
stateMapping: singleIndex(searchIndex),
}}
>
<SearchBox
autoFocus={true}
placeholder="Search"
👉 I got an issue when using queryHook, if remove this, everything works fine
queryHook={queryHook}
/>
....
</InstantSearch>
</InstantSearchSSRProvider>
);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I sync the search state with the url. For example, when I visit
/search?query=Algolia
, I expect the initial load will have the query "Algolia" and filter the results accordingly. It works perfectly fine.However, the initial load doesn't include the "query=Algolia" when I try to use the
queryHook
to debounce the search. Instead, it just sends an empty query.What would be the issue here and how could I solve that?
Beta Was this translation helpful? Give feedback.
All reactions