instantsearch icon indicating copy to clipboard operation
instantsearch copied to clipboard

Guidance: Re-render InfiniteHits based on time without calling search api

Open reedyrm opened this issue 7 years ago • 2 comments

Is your feature request related to a problem? Please describe 🙏 I have an index that contains Restaurants where each restaurant has a specific open/close time and location which depending on the day of week/time in the object. Depending on the time when the Restaurant object is rendered, it may appear in my results or not. I'm looking for a way to re-render my current results as the time changes without making a new API call.

Describe the solution you'd like 🤔 I want to re-render a Custom Component that is wrapped in the connectInfiniteHits without making an additional call to the Algolia API.

Describe alternatives you've considered ✨ My first reaction is to use a piece of state that is updated every minute that is used as part of the key in the render, but I think that would call the Algolia API to get more results

Additional context Add any other context or screenshots about the feature request here.

I'm looking for guidance on how I would re-render a Custom Component using connectInfiniteHits.

reedyrm avatar Feb 26 '19 17:02 reedyrm

The easy way to re-render is indeed to call the Algolia API every N seconds/minutes. If you don't want to go that path you can save the last renderOptions and call the render function with the saved values + the updated value. Here is an example that show how to implement this solution. It's not the more elegant solution but it works.

samouss avatar Feb 26 '19 18:02 samouss

This is perfect. Thanks for your response!

reedyrm avatar Feb 26 '19 23:02 reedyrm