Refresh does not request pages in infinite hits again
See original GitHub issueDescribe the bug 🐛
When updating the refresh
token, infinite hits will not react to the refetch.
To Reproduce 🔍
Steps to reproduce the behavior:
- go to the example
- trigger next page
- refresh
- see no changes in the infinite hits, even if the index would have changed
The example’s index can be changed to an index you control where you make changes to make the effect clearer.
Expected behavior 💭
Infinite hits reacts to refresh, either by:
- clearing the cache completely and restarting on the current page
- clearing the cache and the state and restarting on page 0
Likely we should go for option 2, unless there’s a showPrevious.
Additional context
Add any other context about the problem here.
When refresh happens, we need to make sure the infinite hits internal cache is also invalidated.
On React Native, where the list component itself is stateful, we can not rely on the “key” hack, because it rerenders with an empty state when we simply clear the cache. What could be an option is:
- clear cache
- redo current search
- save in cache
- rerender
The problem is that you can’t do that as a user reasonably, since you don’t have access to the helper state.
A possible solution is:
In the function refresh
in InstantSearchManager, emit an event to all widgets. Then in InfiniteHits, listen to that event, and clear the internal cache as we expect.
Another potential solution is to return a promise from the search
which happens in refresh. This should allow people to rerender the InfiniteHits component manually.
Relevant pieces of code:
Relevant issues:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:60 (22 by maintainers)
Top GitHub Comments
Yes, the connector will accept the cache prop as well @meck93. You can check that by using a custom cache which has some logging 😃
Hi all,
I was just wondering whether there was any update to this? I’m still having a little trouble “rolling my own” infinite hits using the API. My setup requires the ability to search, show no duplicated results, have infinite scroll etc. Everything with the ConnectInfiniteHits works except the problem stated above.
Thanks in advance, Alex