Feature Request: async cache-busting
See original GitHub issueRequest
The ability to empty <Select.Async/>
's cache.
Use Case
We have a fairly search endpoint with parent-child data, where we only want to reveal the child data when the parent value is already “enabled” somewhere.
Example: there is a location ‘New York’ in USA and ‘York’ in the UK. When supplying ‘York’ to our search API, it will return nothing if neither USA or UK are enabled, [New York]
when USA is enabled, and [New York, York]
when both USA and UK are enabled.
The problem is that because the search string is the same, the smart cache prevents the new request from being made.
Proposed Interface(s)
1. Second argument to loadOptions()
Something like invalidateCache: boolean
. Pretty straightforward. For future proofing, maybe an options
object would be good as well.
2. Allow ref
s to provide access to an instance method invalidateCache()
Would instantly empty the cache. This method provides the most flexibility but is also a bit messy and imperative. A similar approach is used in react-virtualized
forceUpdateGrid()
.
<Select.Async ref={node => this.Async = node}/>
// when desired
this.Async.invalidateCache();
It’s a pretty trivial feature to implement, so depending on how acceptable the proposed interfaces are, I can send a PR asap. Thanks! 😃
(Question re: v2 – are releases for v1 still planned / PRs for v1 still accepted?)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
I use v3.0.4 and I’m struggling with some kind of funky behavior probably due to the cache. I have
cacheOptions={false}
in an async select being populated through fetch/promise calls but it does not seem to be doing what its name says. The console.log shows the correct data at each call but the list is populated with partly wrong data 😕 Any update on either a fix or a workaround on this matter ? Thanks!This issue is resolved for me, so closing this. Thanks all!