Before:
├── @tanstack/react-query@4.14.6
├── @trpc/client@10.0.0-rc.4
├── @trpc/next@10.0.0-rc.4
├── @trpc/react-query@10.0.0-rc.4
├── @trpc/server@10.0.0-rc.4
After:
├── @tanstack/react-query@4.14.6
├── @trpc/client@10.4.3
├── @trpc/next@10.4.3
├── @trpc/react-query@10.4.3
├── @trpc/server@10.4.3
Here's the code throwing an error after I updated tRPC.
import { useStore } from 'src/store/store'
import { trpc } from 'src/utils/trpc'
export const useMutateItem = () => {
const utils = trpc.useContext()
const reset = useStore((state) => state.resetEditedItem)
const createItemMutation = trpc.item.createItem.useMutation({
onSuccess(input) {
const previousItems = utils.item.getAllItems.getData()
if (previousItems) {
utils.item.getAllItems.setData([...previousItems, input]) // Error message below
}
reset()
}
})
// ...
return { createItemMutation, ... }
}
(method) setData(input: void | undefined, updater: Updater<(Item & {
tags: Tag[];
})[] | undefined, (Item & {
tags: Tag[];
})[] | undefined>, options?: SetDataOptions | undefined): void
@link — https://react-query.tanstack.com/reference/QueryClient#queryclientsetquerydata
Expected 2-3 arguments, but got 1.ts(2554)
utilsProxy.d.ts(46, 45): An argument for 'updater' was not provided.
To clarify the method;
setData(input: void | undefined, updater: Updater<...>, options?: SetDataOptions | undefined): void
I guess the problem is that the 'input' argument has to be either void or undefined. How can I solve this? What's the difference between 'queryKey' on TanStack Query Documentation and 'input' in tRPC wrapper? There was a bug report on GitHub but maybe unrelated.