Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

fix(infiniteHits): do not cache the cached hits #3011

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

eunjae-lee
Copy link
Contributor

@eunjae-lee eunjae-lee commented Feb 18, 2021

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.

@codesandbox-ci
Copy link

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:

Sandbox Source
react-instantsearch-app Configuration
routing-basic Configuration

Copy link
Contributor

@Haroenv Haroenv left a 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();
Copy link
Contributor

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!

Copy link
Contributor Author

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!

Copy link
Contributor

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

@algobot
Copy link
Contributor

algobot commented Feb 18, 2021

Deploy preview for react-instantsearch ready!

Built with commit b2d1922

https://deploy-preview-3011--react-instantsearch.netlify.app

@eunjae-lee eunjae-lee merged commit b56f5f7 into master Feb 19, 2021
@eunjae-lee eunjae-lee deleted the fix/infinite-hits-cache branch February 19, 2021 08:35
@alexpchin
Copy link

@Haroenv Do you know when this will be released?

eunjae-lee added a commit that referenced this pull request Feb 23, 2021
# [6.10.0](v6.9.0...v6.10.0) (2021-02-23)

### Bug Fixes

* **infiniteHits:** do not cache the cached hits ([#3011](#3011)) ([b56f5f7](b56f5f7))

### Features

* **smartSort:** add widget ([#3009](#3009)) ([4cc8412](4cc8412)), closes [#3010](#3010)
@eunjae-lee
Copy link
Contributor Author

@alexpchin It's just released in 6.10.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants