Replies: 1 comment
-
In theory this should work, but I indeed wonder if something is keeping the items cached, or maybe a cleanup happens when the options change. Alternatively to your current option, what you can do as well is a static list for If that doesn't work (maybe it doesn't trigger a change/render), I think you could use I've never seen the use case of dynamic sortBy options. There definitely could be a bug going on as it's not a common pattern. Do you think you could create a reproduction in codesandbox, or maybe even in a test for the repo? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I'm using React Instantsearch, and the
SortBy
widget (actually I'm using hooks and custom UI, but I'm hitting the same issues if I use the prebuilt widget).Depending on some options the user changes in the UI (particularly, which result types they want to see), I want to dynamically change the available sort options, since some don't make sense in certain situations. As a concrete example, we have menu for result type, which can be product, recipe, or article. Unless the user is searching for recipes, the sort option "cook time" makes no sense, and we want to hide it.
I've tried various approaches but no matter what I try, when I change the available sort options passed to SortBy, Instantsearch seems to get into an inconsistent state and I see unexpected and buggy behaviour. It gets buggy even if I ensure I'm not surprising it by removing an option currently in use.
I don't know if I'm doing something wrong, or this is unsupported and failing is expected, or if I'm running into a bug.
Here's one iteration of the code I was using.
Is there anything wrong with what I'm trying to do? Ought it be possible? Is it a supported feature? Is it a bug?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions