-
Hi guys, I hope you're doing well I am using the react-instantsearch v7.5.0 and Next js. I am trying to add some analyticsTags to the component based on my current applied filter. For example If I have select the category of "cars" I need to update the analyticsTags value. The issue is that when I do that it caused a state change and I can see from the network that another request was made just because I updated the analyticsTags. Is there a way I can do this without causing a refetch. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you want to update parameters outside of the InstantSearch life cycle, I suggest that you actually keep track of them outside and apply it to the final "search" request outside like this: const searchClient = algoliasearch('','');
const searchFn = searchClient.search;
searchClient.search = function search(queries) {
return searchFn(queries.map(({ params, ...rest, }) => ({ ...rest, params: { ...params, analyticsTags: [...] }}))
} |
Beta Was this translation helpful? Give feedback.
-
@Haroenv thank you answering. This fixes all my problems 🥹 |
Beta Was this translation helpful? Give feedback.
If you want to update parameters outside of the InstantSearch life cycle, I suggest that you actually keep track of them outside and apply it to the final "search" request outside like this: