Replies: 1 comment 3 replies
-
I think the key is the identifier of the resource, but fetcher is just a way to get that resource. So using the same key but different fetchers doesn't make sense to me, maybe you can add an extra argument to mark them as different: useSWR([arg, 'type1'], fetcher1)
useSWR([arg, 'type2'], fetcher2) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As everyone knows, useSWR caches fetcher results based on the key.
I used a custom fetcher to handle asynchronous requests.
The key is passed to the argument of the fetcher.
There is some inconvenience in this process.
If using the same arguments, you will use the same key.
Using the same arguments will use the same cache even if the fetcher is different.
Even if the keys are the same, if the fetcher is different, I think the cached data should be separated.
In my opinion, there is no reason why the results should be the same if the fetcher is different.
To fix it, what do you think about using the fetcher on serializing the key?
Beta Was this translation helpful? Give feedback.
All reactions