TanStackT
TanStack3y ago
1 reply
dual-salmon

MutationKey null when using persistQueryClient

Hi, I am using persistQueryClient for caching mutations and queries when the user is offline. It works well for queries, but not for mutations. When using the custom hook useCreateTodo, I am getting a mutationKey of [null]. However, if I import the useMutation hook and use it like this: useMutation({mutationKey:['create-todo']}), it works when I restarts the app.

I already have a mutationDefaults
queryClient.setMutationDefaults(['create-todo'], {
  mutationFn: createTodo
});
Was this page helpful?