-
Notifications
You must be signed in to change notification settings - Fork 391
Clear all current refinements #3252
Comments
unlike the current major version, clearRefinements has its own connector: import connectClearRefinements, {
ClearRefinementsConnectorParams,
ClearRefinementsWidgetDescription,
} from 'instantsearch.js/es/connectors/clear-refinements/connectClearRefinements';
import { useConnector } from 'react-instantsearch-hooks';
type UseClearRefinementsProps = ClearRefinementsConnectorParams;
function useClearRefinements(props: UseClearRefinementsProps) {
return useConnector<
ClearRefinementsConnectorParams,
ClearRefinementsWidgetDescription
>(connectClearRefinements, props);
} Then you can use |
@Haroenv thanks, this worked great! Maybe not the right place to ask this, please direct me to where questions are more suitable if it's not here. But I'm experiencing some extra round trips to Algolia after moving to the hooks API. For instance with the dom package I could have a structure like this:
and this would be fine and only do one round trip to Algolia when I opened a page. Now when I have a similar structure with the hooks API the same page open has 3 or 4 round trips to the Algolia servers. One thing I'm seeing is that when I change the number of hits to fetch using useHitsPerPage the initial couple of round trips to the servers just have the default number of hits in them. What would be the right way to get a custom number of hits on the first round trip using the hooks api? |
@mellson Thanks for all these reports on the Hooks package. Could you please create a sandbox that shows these round trips to the Algolia servers? (If you don't mind, a new GitHub issue would be appropriate.) |
@francoischalifour thanks, I'll create a new issue if I can recreate this in a sandbox. |
@francoischalifour just a quick update, I think it was a problem with concurrent mode in the version of React 18 I was using: |
Sounds good鈥攖hanks for letting us know. |
馃悰 Bug description
I'm missing a way to clear all current refinements using the hooks api.
Maybe I'm missing something, but with
useCurrentRefinements
there's only an option to clear 1 refinement at a time, which will lead to a new search per refinement being cleared.With the dom package it's possible to clear all refinements at once.
The text was updated successfully, but these errors were encountered: