react-query-auth
                                
                                
                                
                                    react-query-auth copied to clipboard
                            
                            
                            
                        refetchUser function example/ invalidate auth-user
Hi,
Can you please provide an example of how to force a user refetch? The docs mention a refetchUser function but that is not used anywhere in the demo. I've tried invalidating the query key after a mutation but that doesn't force a refetch either.
Thanks!
You just need to call the refetchUser() function. So, something likes this:
const { user, refetchUser } = useAuth();
const myFunction = async() => {
    try {
        await myApiCall();
        
        // if  the result of the above function is success, user data is changed and we want to refetch the user 
        await refetchUser();
    } catch (error) {
        //...
    }
}
What happens here is that refetchUser() invokes the loadUser() function that you have to create in your auth provider.