Replies: 3 comments 2 replies
-
you mean fire off a But it's definitely possible: query/packages/query-core/src/tests/utils.ts Lines 35 to 44 in 5d29f8f |
Beta Was this translation helpful? Give feedback.
-
@TkDodo How do you do it for V4? |
Beta Was this translation helpful? Give feedback.
-
Hi, I've got quite the edge case where I also need to fire a mutation outside of react. export const updateProcess = async () => {
queryClient.getMutationCache().find({ mutationKey })?.execute();
}; and export const updateProcess = async () => {
const mutation = queryClient.getMutationCache().find({ mutationKey });
if (mutation ) {
queryClient.getMutationCache().build(
queryClient, mutation.options, mutation.state.variables
).execute();
}
}; but none of them works. In both cases the onMutate function throw an error saying that the expected params is undefined. Is there any way to do this or is it a stupid idea ? Btw I'm using react-query v4 |
Beta Was this translation helpful? Give feedback.
-
How we can mutate data outside of react component?
Searching offer not working solution to use 'mutate' method of application's instance of QueryClient...
which looks pretty logical but instance of QueryClient does not contain such a method
Beta Was this translation helpful? Give feedback.
All reactions