How do I stop a mutation from updating state #6762
Replies: 2 comments
-
calling |
Beta Was this translation helpful? Give feedback.
-
Thanks @TkDodo , obvious answer, but good to call out. I'm specifically referring to the case, where we've already called the Some examples:
I was thinking of something along the lines of the Saying that, it may not be possible, as the wrapper hook (e.g. I'll close this ticket, but will leave it as a placeholder in case anyone else desires this behaviour. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Aside from the other mutation questions around cancelling inflight mutation updates...
I was wondering if mutations had the ability to not trigger a state update.
In my scenario, I have a frequent task (i.e. mouse hover action), and I only want to apply the mutation if the data has changed (e.g. hovering over a new element).
The problem is, the (parent) React Component state is updating every time the
useDoFrequentThing.mutate({ ... })
hook is called.I can move the logic to conditionally call
.mutate()
to outside of the mutation - which reduces the constant state updates.However, I'd prefer to have the conditional logic inside the mutation, as it's called from numerous locations.
Is there a way to do this?
e.g.
Beta Was this translation helpful? Give feedback.
All reactions