-
I'm having problems to type a fetch function from a useMutation const queryClient = useQueryClient();
const { mutate: mutateCloseStatus } = useMutation(
(id: number, newValue: 0 | 1) => changeClosedStatus(id, newValue),
{
onSuccess: () => {
queryClient.invalidateQueries(`topic:${topicId}`);
},
}
); export async function changeClosedStatus(topicId: number, newValue: 0 | 1) {
const response = await api.put(`forum/topic/close/${topicId}`, {
closedStatus: newValue,
});
return response;
} what should i do? |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Nov 26, 2022
Replies: 1 comment 1 reply
-
a mutation can only accept one parameter, not many. if you need multiple parameters, pass an object. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hiwyn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a mutation can only accept one parameter, not many. if you need multiple parameters, pass an object.
https://tkdodo.eu/blog/mastering-mutations-in-react-query#mutations-only-take-one-argument-for-variables