Closed sallomendo closed 2 years ago
@sallomendo Ask a DX question. Should we need to remove the previously cached data when the key is updated?
@wellyshen I donโt think so, we can use the clearCache function inside a useEffect hook, I think we should leave that to the dev.
@sallomendo Sorry quite busy recently, would you mind to give me a PR for this issue?
@sallomendo This issue has been fixed in the latest version.
@wellyshen thanks for working on this, I will close the pr I created for this.
@sallomendo Sorry I didn't note that, thank you!
Bug Report
Describe the Bug
fetchPredictions
callback is not updating whencache
orcacheKey
changes.How to Reproduce
When the cache key is stateful, the window storage key doesn't change.
Expected Behavior
The cache and cache key should change when you pass a different value.
Your Environment
Additional Information
I think we need to add
cache
andcacheKey
as a dependency to theuseCallback
hook here https://github.com/wellyshen/use-places-autocomplete/blob/master/src/usePlacesAutocomplete.ts#L155