Global mutate doesn't work #746
Replies: 3 comments
-
if you have two hooks mounted const { data, error } = useSWR('/api/tasks')
const { data, error } = useSWR('/api/tasks?limit=3&contactId=30404') call For more informations, you could check the mutation section in docs |
Beta Was this translation helpful? Give feedback.
-
@promer94 Then isn't the global mutate pretty useless? Obviously I can't make |
Beta Was this translation helpful? Give feedback.
-
This is expected exactly like @promer94 said, so you won't accidentally request something unintended. However if you want to revalidate some data without knowing the key, you can only use an internal API for now (might be changed in the future): https://github.com/vercel/swr/blob/master/src/cache.ts. You can basically get all the keys from there and find the ones with the same API path and mutate them. We can work on a new API for this case (like accepting a filter function for |
Beta Was this translation helpful? Give feedback.
-
Bug report
Description / Observed Behavior
I want to revalidate the data/send a new request using the global mutate function.
Expected Behavior
To send a new request.
Repro Steps / Code Example
I'll just post a code snippet as I am not doing anything fancy.
and then when I use the global mutate function
mutate('/api/tasks')
Now I am not adding the query and I assume thats how it should work. Because I don't have access to contactId in every instance.
Beta Was this translation helpful? Give feedback.
All reactions