T
TanStack4w ago
helpful-purple

Cannot read properties of undefined (reading 'isDehydrated')

Whenever the dev server reloads, I keep seeing this error and after I refresh manually, this goes away
No description
3 Replies
helpful-purple
helpful-purpleOP4w ago
This is only happening when I try import react queryClient from my src/utils folder I made the declaration inside the createRouter route function itself Now my question is that how can I access this queryClient in my utils function? I know we can access if we are in a component using Route.useRouteContext().queryClient
extended-salmon
extended-salmon4w ago
I am also running into this, please let me know if you have an answer
helpful-purple
helpful-purpleOP4w ago
@Winston hey, as I said I stopped seeing that error when I stopped importing queryClient. I made the declaration inside the src/router.tsx file. Now when I need to access queryClient, I used useQueryClient and its working fine.
export function useUpdateConversation() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (input: Message.CreateInput) => updateConversation(input),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({
queryKey: ["conversation", variables.conversationID],
});
},
});
}
export function useUpdateConversation() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (input: Message.CreateInput) => updateConversation(input),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({
queryKey: ["conversation", variables.conversationID],
});
},
});
}

Did you find this page helpful?