swr-site
swr-site copied to clipboard
Feedback for “Mutation – SWR”
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?