-
Notifications
You must be signed in to change notification settings - Fork 48.4k
When calling a useTransition startTransition callback outside of event handlers, isPending is never set to true #17272
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I guess startTransition is never intended to be used in effects. I didn't expect it even works. |
Ok @dai-shi but the use cases is interesting. |
Do you think this is the same as #17279? |
Yes, I believe that's the same issue. |
Hello, I think I have a similar issue when using |
@kentcdodds you can see the isPending is |
I'm seeing the same behavior as @lintuming - setting |
That is a bug we need to fix regardless. |
Fixed by #17382. Updated Sandbox: https://codesandbox.io/s/usetransition-useeffect-issues-ccq5e |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
isPending
is never set to true when callingstartTransition
withinuseEffect
, but it does work properly when within auseLayoutEffect
.https://codesandbox.io/s/usetransition-useeffect-issues-p1j9s
Here's the correct behavior (accomplished via
useLayoutEffect
):Here's the incorrect behavior (via
useEffect
):Note the difference is that the opacity never changes to 0.4 (which is determined based on the
isPending
state).What is the expected behavior?
I expect them to both behave the same (at least as far as the user can observe).
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
The text was updated successfully, but these errors were encountered: