How to use the queryHook with useSearchBox from react-instantsearch-hooks?


Unfortunately I’ve ran into an issue that that I am too stupid to figure out. Specifically, what is the proper way of using the queryHook with useSearchBox? As soon as I put this code in:

const { query, refine } = useSearchBox({
    queryHook(query, search) {

react goes into an infinite loop of “Warning: Maximum update depth exceeded. …”.

I saw this note in the documentation:

When you provide a function to Hooks, make sure to pass a stable reference with useCallback() to avoid rendering endlessly. Objects and arrays are memoized so you don’t have to stabilize them.

but I am not sure how to do that properly? Could somebody give me a hint please?

Thank you!

1 Like