swr-site icon indicating copy to clipboard operation
swr-site copied to clipboard

Feedback for “Mutation – SWR”

Open m3c-ode opened this issue 2 years ago • 0 comments

Hi there,

I have tried everything I could so far, but can't get to make this manual data revalidation/mutation to work using const { mutate } = useSWRConfig().

I have tried setting GlobalConfing on my app, and not.

For example: In my "AddressesList" component, I fetch addresses list using the hook: const { data: fetchedAdrsList, isValidating, error: isAdrsError} = useSWR('v1/addresses', fetchMyAddresses, { revalidateOnFocus: false, revalidateIfStale: false, });

Then in another component, after creating a new address, I use: const { mutate } = useSWRConfig(); ... mutate('v1/addresses')

and on success, I am redirected to the AddressesList. But my data list is not updated with the new address... how is that supposed to work?

m3c-ode avatar Nov 22 '22 21:11 m3c-ode