I am checking out trpc with t3 stack and I want to update a state when useQuery is successful.
and I am getting typescript error on the frontend,
Argument of type '{ onSuccess: (shoppingList: ShoppingItem[]) => void; }' is not assignable to >parameter of type 'void'.
I am doing something like this on my frontend,
const [items, setItems] = useState<ShoppingItem[]>([]);
const { data: itemsData, isLoading } = trpc.item.getItem.useQuery({
onSuccess: (shoppingList) => {
setItems(shoppingList);
},
});
this is my backend route,
getItem: publicProcedure.query(async ({ ctx }) => {
const items = await ctx.prisma.shoppingItem.findMany();
return items;
})