mutationFn not found.
const usePost = createQuery({ queryKey: ["posts"], fetcher: (variables: Variables): Promise<Data> => { return fetch(/posts/${variables.id}`).then((res) => res.json());
},
// u can also pass middleware to cutomize this hook's behavior
});
const useAddTodo = createMutation({ mutationFn: async (variables: { title: string; content: string }) => fetch("/post", { method: "POST", body: JSON.stringify(variables), }).then((res) => res.json()), }); ` mutationFn throws type error with "@tanstack/react-query": "^5.51.11".
Can you provide me a codesanbox example? I can not reproduce this issue
I also encountered this issue but turns out that I had not installed @tanstack/react-query itself. I just ran pnpm add @tanstack/react-query and the issue was solved
I also encountered this issue but turns out that I had not installed
@tanstack/react-queryitself. I just ranpnpm add @tanstack/react-queryand the issue was solved
I understand these packages are used together, but it's interesting it's not listed as an explicit requirement anywhere here. Anyway, thanks for this information, I was also running into this issue today and including this package resolved the error.