react-query-kit icon indicating copy to clipboard operation
react-query-kit copied to clipboard

mutationFn not found.

Open dev-seahouse opened this issue 1 year ago • 3 comments

Screenshot 2024-07-22 at 2 38 54 PM 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".

dev-seahouse avatar Jul 22 '24 06:07 dev-seahouse

Can you provide me a codesanbox example? I can not reproduce this issue

liaoliao666 avatar Jul 22 '24 07:07 liaoliao666

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

khaitbek avatar Apr 10 '25 04:04 khaitbek

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 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.

mbrzuzy avatar Jul 10 '25 13:07 mbrzuzy