algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

result list with hits get reset when component with “useSortBy” hooks is closed #3635

Closed rosnk closed 1 year ago

rosnk commented 1 year ago

I am using "import { useSortBy } from "react-instantsearch-hooks", to create a sortby dropdown in expo project(react native). This sort by component is inside parent component, which opens like model.

Problem: sorting works fine while i open the filter component and choose different filter(ex by price desc, price asc), but as soon as i close the model, whole shorted list result is reset... basically result does not stick to the my choosen sorted result.

video: https://youtu.be/J5uZF01lVtU

pic1: before any sorting, results are as in pic:

pic2: i click the filter, which shows component similar to model, where i can choose dropdown filter, results after i click desc(which is working fine while, filter screen is still showing):

pic3: once i click the filter icon to remove the filter screen, result does not stick to price by desc, it resets to original result:

here is the source code in snack: https://snack.expo.dev/@rosnk/algoli_sortby_example_buggy

note: ( snack code is perfectly fine.... snack is showing error on import line of algolia... that is on this line: import { InstantSearch } from "react-instantsearch-hooks";

FabienMotte commented 1 year ago

We're doing a round of cleanup before migrating this repository to the new InstantSearch monorepo. This issue is a duplicate of https://github.com/algolia/instantsearch.js/issues/5240 so we're going to close it.

Two possible workarounds are listed here: https://github.com/algolia/instantsearch.js/issues/5240