Replies: 4 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 |
|
@TkDodo How do you do it for V4? |
|
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 |
|
I want to rebump this for query@v5. I too have the need to imperatively add data to the mutationCache (we have to react to a redux event in a saga (I know, I know)). For QueryCache, this is handled by I was a bit surprised to see the docs for Should I take these methods being undocumented to mean these are meant to be private? How "dangerous" is it to try and call these manually? query/packages/query-core/src/mutation.ts Line 176 in f6ae1cc |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
All reactions