- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 40
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Transition issue #227
Comments
Will look into it soon, thank you for providing a reproduction example. |
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. |
#230 adds |
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 |
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. |
…to return object (#230) This PR introduces a workaround for the issues described in #227, by adding `isTransitioning` and `isPending` shorthand statuses to the hooks return object. `isTransitioning` is the value returned from the `useTransition` hook that is used under the hood, while `isPending` has the value of `isExecuting || isTransitioning`, for convenience. re #227
Added documentation for checking action status on the docs website: here. |
…to return object (#231) This PR introduces a workaround for the issues described in #227, by adding `isTransitioning` and `isPending` shorthand statuses to the hooks return object. `isTransitioning` is the value returned from the `useTransition` hook that is used under the hood, while `isPending` has the value of `isExecuting || isTransitioning`, for convenience.
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
The text was updated successfully, but these errors were encountered: