Replies: 5 comments 6 replies
-
I think you could use the useEffect hook to achieve this const { data } = useSWR('/api')
useEffect(() => {
if(data) {
// show notification
}
}, [data]) |
Beta Was this translation helpful? Give feedback.
-
Try to do something with the options useSWR('/api', { onSuccess: (data, key, config) => { /* do whatever you want */ }}) |
Beta Was this translation helpful? Give feedback.
-
I found |
Beta Was this translation helpful? Give feedback.
-
You can probably also use something like |
Beta Was this translation helpful? Give feedback.
-
I'm looking for a way when the data has changed to trigger another call to refetch the data. I'm not sure this is a very good practice to do this way but... {
onSuccess: async (newData) => {
const equal = dequal(oldData.current, newData);
oldData.current = data;
if (!equal) {
await mutate(keyForADifferentMutation);
}
},
}, I didn't use compare because I didn't want the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using SWR to fetch new data, but I want to show a notification when has new data was fetched.
Any idea for me. Thanks
Beta Was this translation helpful? Give feedback.
All reactions