-
Notifications
You must be signed in to change notification settings - Fork 25
Ability to manually clear a cache #25
Comments
There are no plans for it currently. I think with concurrent React hopefully so close to launch that they will cover this use case. Concurrent React will likely render this package obsolete. While I don't intend to do it myself given the unknown of when concurrent React will be publicly available, I would welcome a PR that handles this. |
How does this look? master...ryanberckmans:f11e2b43a57bb314f7aa45aae56acf3f45d3076c |
I've just been playing with this and after some false attempts I came up with a simple to implement solution. I added |
How would you use this? I made a normal call to get my data and then wanted to clear the cache because I've done an update. I found that if I tried a second call of useFetch with the flag to clear the cache it would be in some conditional part of my code and so fails one of the rules of hooks. |
Aidan,
I wrap calls to useFetch in an anonymous function that passes evict: true
for only the first invocation of useFetch. The same anonymous function
returns a read() interface similar to relay so that I can kick off useFetch
requests in parallel with rendering, ie. before passing them into child
components.
The rules of hooks eslint rule failed for me too. I think it's because of
the name "useFetch".
…On Thu, Jun 18, 2020, 8:36 AM Aidan Nichol ***@***.***> wrote:
How does this look?
master...ryanberckmans:f11e2b43a57bb314f7aa45aae56acf3f45d3076c
<master...ryanberckmans:f11e2b43a57bb314f7aa45aae56acf3f45d3076c>
How would you use this? I made make a normal call to get my data and then
wanted to clear the cache because I've done an update. I found that if I
tried a second call of useFetch with the flag to clear the cache it would
be in some conditional part of my code and so fails one of the rules of
hooks.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACJCPA3QM25ZFHIAHBNZ33RXIJ65ANCNFSM4JNUYWXA>
.
|
Hello!
Thanks for this great library. It's been super helpful and works well.
I'm wondering if its going to be possible ever to trigger a manual cache clear. Say we are loading a user profile on page load. That data doesn't change often, and can be cached. If a user updates their profile though, we will need the ability to clear the cached response in order to trigger a refetch.
Hope this makes sense as a use case, and thanks again!
The text was updated successfully, but these errors were encountered: