-
Notifications
You must be signed in to change notification settings - Fork 385
fix(infiniteHits): do not cache the cached hits #3011
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b2d1922:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan, thanks!
if (this._cachedHits === undefined) { | ||
this._cachedHits = cache.read({ state: searchState }) || {}; | ||
} | ||
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a very important fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it especially makes sure to take cache
prop into account even when user passes a different object!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and makes sure we don't recreate the memory cache on every render
Deploy preview for react-instantsearch ready! Built with commit b2d1922 https://deploy-preview-3011--react-instantsearch.netlify.app |
@Haroenv Do you know when this will be released? |
@alexpchin It's just released in 6.10.0 |
Summary
This PR fixes the bug where InfiniteHits stored the cached hits, so clearing cache didn't make any effect.
Result
InfiniteHits reads cache object everytime and do not store it inside the connector itself.