Add artificial delay option for mutations #4400
Unanswered
lucasmotta
asked this question in
Ideas
Replies: 1 comment 1 reply
-
This is definitely not something that I see handled by react-query out of the box:
all of these are imo better options than to increase the api surface to "make things slower". You're the first to complain about things being too fast 😅 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
So after watching this video of Sam Selikoff about artificial delay on mutations, I've been thinking that it would be a great addon for react-query's
useMutation
hook.In some situations it would be beneficial for the UX to delay the mutation by a couple ms, so you don't end up in a state where you see a
isLoading
state blinking because the mutation happened too fast.I know this can be achieved with
mutateAsync
, but that adds quite a bit of boilerplate on user land.So my suggestion is to have an
artificialDelay
prop that would add this min request time for the mutation:As pointed by @lukemorales, this can somehow be achieve with this pattern:
But that's set globally and the user overrides the
onMutate
prop, they would have to manually set thewaitMilliseconds
again.Beta Was this translation helpful? Give feedback.
All reactions