Replies: 7 comments 1 reply
-
Will look into it soon, thank you for providing a reproduction example. |
Beta Was this translation helpful? Give feedback.
-
Update: this problem is quite complex. If I use just The thing is: if I return the value of If you have any ideas please let me know, I'm still trying to figure out what's the best way to fix this issue while keeping the correct callbacks behavior. |
Beta Was this translation helpful? Give feedback.
-
#230 adds |
Beta Was this translation helpful? Give feedback.
-
I concede this is a complex one… Maybe we could use some memoization with request ID to avoid callback getting triggered twice (if it has already been triggered, a flag is turned on), something similar we do with one-time My first question is: are you really sure that I think we have to make some tradeoffs. But returning multiple fields as you did in the #230, could be a nice first workaround. Something similar is done by react-query with the pending state. So at first I'm ok with it. We just need to document it well. I'll think about it further. But currently, I'm forced to manage useTransition outside. Maybe we could fake the |
Beta Was this translation helpful? Give feedback.
-
That was my question as well when I first saw the
Nice, I agree. It will improve the UX for the time being.
Yeah, very hacky, I'll see if I can come up with a nice working solution. If you think you've found one, feel free to submit a PR with a proper fix. I'll keep this issue open for now. |
Beta Was this translation helpful? Give feedback.
-
Added documentation for checking action status on the docs website: here. |
Beta Was this translation helpful? Give feedback.
-
Converted the issue into a discussion, since the workaround offers an actual fix for the issue you originally described. |
Beta Was this translation helpful? Give feedback.
-
Are you using the latest version of this library?
Is there an existing issue for this?
Describe the bug
Hello @TheEdoRan
I've already detailled everything here, just added a repro. For me this is a bug.
#218
Reproduction steps
Try both buttons, in the actual pattern because
isExecuting
is back tofalse
, before the redirect occurs you get small glitches on redirects.Click the one that uses
useAction
after the 3 seconds delay, you quickly getisExecuting
tofalse
.This means the button gets its "clickable" state again for milliseconds, before getting redirected.
Adding the state from the transition (named
isPendingTransition
) toisExecuting
as a second requirement seems a quick fix, currently, you're just discarding it.✅ Expected behavior
Click the button that uses
useTransition
, and when the 3-second delay finishes, you get redirected without a UI glitch. (becauseisExecuting
is back tofalse
, before the redirect occurs)Maybe
isExecuting
could be:isExecuting && isPendingTransition
instead ofisExecuting
?isExecuting (internal) && isPendingTransition (from useTransition)
Minimal reproduction example
https://codesandbox.io/p/devbox/repro-bug-qs8svh
Operating System
MacOS
Library version
7.4.3
Next.js version
14.2.1
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions