Closed
Description
I am trying to use this for a search component, like:
const { status, data, error, isFetching } = useQuery(
searchQuery && ['results', searchQuery],
getSearchAsync,
);
I would like the call to getSearchAsync
to be debounced while the user is typing the query. Tried adding lodash.debounce like:
const { status, data, error, isFetching } = useQuery(
searchQuery && ['results', searchQuery],
debounce(getSearchAsync, 3000),
);
But since this is a function component it is not working as expected. The getSearchAsync
method is only called multple times after the timeout expires, which I expect to be once with the latest value (searchQuery).
Metadata
Metadata
Assignees
Labels
No labels