Skip to content
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

Delay setting useTransition isPending to true until JND #18595

Closed
subhero24 opened this issue Apr 14, 2020 · 9 comments
Closed

Delay setting useTransition isPending to true until JND #18595

subhero24 opened this issue Apr 14, 2020 · 9 comments

Comments

@subhero24
Copy link

Do you want to request a feature or report a bug?
Maybe a feature?

When using Suspense and useTransition, the isPending of useTransition is immediately set to true.
I want to show a spinner when a transition is still pending, but showing it immediately results in a flashing spinner when the underlying promise resolves very fast. This is not a nice experience.

Is there a useTransition suspense option to delay the isPending indicator? I want to prevent the spinner from showing if the transition completes in for example 100ms.

@subhero24 subhero24 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 14, 2020
@aweary aweary added Resolution: Support Redirect and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Apr 14, 2020
@aweary
Copy link
Contributor

aweary commented Apr 14, 2020

@subhero24 this is addressed in the Concurrent Mode Patterns docs, check out Delaying a Pending Indicator. If you have other questions, check out our community support resources. Hope that helps!

@aweary aweary closed this as completed Apr 14, 2020
@subhero24
Copy link
Author

Ah, forgot it was mentioned in the docs. Thanks!
However, i don't think it solves the problem.

When I set a visibility delay like this with a css animation with for example 500ms, and i want to make sure the spinner does not disappear for 300ms, I have to set the busyMinDurationMs to 800ms. Now all my transitions will take 800ms! If I could have specified the 500ms to useTransition, it could have ignored the busyMinDurationMs if the spinner was not yet shown. And apply a busyMinDurationMs of 300ms if the spinner was already shown. Is there any other solution to this? I think this is something that can not be implemented in "user-land", as useTransition now only allows for a fixed busyMinDurationMs.

@gaearon gaearon reopened this Apr 14, 2020
@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2020

I want to prevent the spinner from showing if the transition completes in for example 100ms.

I think this might have been the intended behavior but we didn't get to implementing it. Or maybe it doesn't always work.

@gaearon gaearon changed the title Suspense delay isPending with useTransition Delay setting useTransition isPending to true until JND Apr 14, 2020
@subhero24
Copy link
Author

I thought maybe that was what the busyDelayMs option was for. But it seems to have no effect when used with useTransition.

@gaearon
Copy link
Collaborator

gaearon commented Jun 29, 2020

Do you have a minimal repro example? A sandbox would be helpful.

@subhero24
Copy link
Author

@gaearon You can find a sandbox here

@subhero24
Copy link
Author

I think maybe this can be closed, as useTransition in the React 18 alpha does not seem to support things like timeoutMs or minBusyMs.

@gaearon I was wondering what the reasoning is for changing this. Does this mean it is now impossible to do a transition with skeleton states? Can such transitions be done in any other way now? Or did it just not have any use cases to do it like that?

@gaearon
Copy link
Collaborator

gaearon commented Jun 9, 2021

I think maybe this can be closed, as useTransition in the React 18 alpha does not seem to support things like timeoutMs or minBusyMs.

I'm not sure. Maybe it still makes sense to automatically delay setting isPending to true until some very little time passes (not configurable)? Or maybe this already happens? It would be good to check.

I was wondering what the reasoning is for changing this. Does this mean it is now impossible to do a transition with skeleton states?

Please see the reasoning in #19703.

@gaearon
Copy link
Collaborator

gaearon commented Jun 22, 2021

Let's track this in #18006 which was filed earlier and is about the same problem.

@gaearon gaearon closed this as completed Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants