Replies: 5 comments 7 replies
-
Having this issue too. I'm forced to conclude showMore no longer works. And the pagination page is ... useless. It gives this as the way to query a specific page: index.search('query', {
page: 2,
hitsPerPage: 5
}).then(({ hits }) => {
console.log(hits);
}); Ok, fine, where's index? How do I figure out what 'query' is supposed to be - the parameter string off the useInstantSearch API??? The documentation of this product is frustrating at best. |
Beta Was this translation helpful? Give feedback.
-
@ldmichae Are you using Multi Index by any chance? That's part of my setup and I'm beginning to suspect it's part of the problem as there are a couple of corner cases using it creates. |
Beta Was this translation helpful? Give feedback.
-
I dropped this into my infiniteHits component useEffect(() => () => console.log('unmount'), []) showMore() is causing the component to be unmounted. That's why it's returning to page 0. So perhaps a reference can be used to recover the state after the immediate remount. |
Beta Was this translation helpful? Give feedback.
-
If it behaves like you describe, that would be a bug. Can you reproduce it with the examples in this repository? Or only with a specific combination of option? If so it would be useful to create a reproduction that clearly shows the issue and we can have a look |
Beta Was this translation helpful? Give feedback.
-
@Haroenv I'd like to pick up on this:
For our purposes, we do conditionally mount our entire InstantSearch component tree. Is the only way to "avoid conditionally mounting any InstantSearch widget" to have a My team is approaching a site redesign as we're going from Next.js 12 to 15, and I want to ensure that I'm recommending best practice as we get into planning. |
Beta Was this translation helpful? Give feedback.
-
Hey there, I'm using the latest version of react-instantsearch (7.13.7 at time of posting) in my project, and recently was tasked with implementing result caching, so that when navigating back to a listing/search page from a detail page, you would maintain your search results and scroll position.
It was easy enough to plug and play with the cache provided out of the box, however I noticed that when using the
showMore
function fromuseInfiniteHits
(paired with a cache instance), it was running requests as if it had no cached information at all, despite loading all cached results appropriately.For example, my PLP (search page) is configured to load results in batches of 12 items. Workflow as follows:
showMore
functionality to request 12 more items.24 cached results are visible as expected. However, when I now call
showMore
, it requests page zero.The next call requests page 1.
This means that I have to invoke
showMore
twice before getting new results (page two).This would mean that if I had requested ten pages before navigation, I would need to invoke
showMore
ten times before getting fresh results.From this description, is it possible to provide any hints as to why
showMore
and the invocation ofuseInfiniteHits
paired with a session cache is not properly paginating so that the first call toshowMore
uses the proper page from the cache?Beta Was this translation helpful? Give feedback.
All reactions