I’m using the react query in my application but the invalidateQueries not working.
This is the acceptFriendshipRequest :
const useAcceptFriendshipRequest = () => {
return useMutation({
mutationKey: ['accept-friendship-request'],
mutationFn: async ({requesterId}: { requesterId: string }) => await acceptFriendshipRequest({requesterId}),
retry: 1,
})
}
export default useAcceptFriendshipRequest;
The setQueryData works correctly but the invalidateQueries to get the profile by id not working, there is no get profile by id in the network :
await queryClient.invalidateQueries({
queryKey: ['get-profile-by-id', user.requester_id]
});
This is the getProfileById function and the query key is totally correct but the fetch not happening :
export const useGetProfileById = (id: string) => {
return useQuery({
queryKey: ["get-profile-by-id", id],
queryFn: async () => await getProfileData(id),
enabled: !!id,
retry: 1,
refetchOnMount: false,
refetchInterval: false
})
};