Replies: 1 comment
-
I just encountered this... I need to fetch the streets for a given city, Once I have the cities from SWR, now I need the streets from SWR. So I have to await a mutate() call for streets with the cityid, however because there's no deduping, I get multiple calls wherever the hook is used. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, have you considered to deduplicate mutate and useSWR?
E.g. you make mutation anywhere (web socket listener, parent component, etc) and no need to revalidate with useSWR in interval. There is such option for useSWR -
dedupingInterval
. It seems good to have the same for mutate -mutate(config, data, { dedupingInterval: 2000 })
It's useful for the cases:
mutate
in web socket listener and show the updated componentPlz consider the example below. https://codesandbox.io/s/busy-mcnulty-lxulf?file=/src/App.js
Thanks
Beta Was this translation helpful? Give feedback.
All reactions