Skip to content

It's confusing that useTransition doesn't do anything outside of user-blocking events #17279

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

Closed
gaearon opened this issue Nov 5, 2019 · 5 comments

Comments

@gaearon
Copy link
Collaborator

gaearon commented Nov 5, 2019

I ran into this when implementing Back button transition in a router. Because the transition is inside a browser popstate event, it gets batched with the low pri update, and the pending state doesn't appear.

I had to do this to work around it but it's unfortunate. We might want to fix this by treating pending state as special. Or maybe a warning — but then we need a first-class official API for opting into user blocking pri.

@dai-shi
Copy link
Contributor

dai-shi commented Nov 5, 2019

the transition is inside a browser popstate event

Ah, I see...

As useTransition doesn't do anything in useEffect, I assumed it's by design.
Is it a bad idea to run the entire callback in user blocking priority?

window.addEventListener('popstate', wrapCallbackWithUserBlockingPriority(handlePopState));
// or even something like ReactDOM.addEventListener('popstate', handlePopState)

I mean the question is only about useTransition, or any other issues suffer from low priority callbacks even if they are user initiated.

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 6, 2019

You generally shouldn't run something with user-blocking priority unless it was actually initiated by user. Back Button is.

@dai-shi
Copy link
Contributor

dai-shi commented Nov 6, 2019

Is it only popstate that we want to raise the priority? It's such a special case then.

@jihlstrom
Copy link

I have been playing around with concurrent mode and I'm impressed with how well the pieces fit together and easy it is to design complex transitions. Well done!

Regarding transitions, does it make sense to do a timeout on the initial render? and in case it does, how would I go about doing that?

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 15, 2019

Closing as a duplicate of #17272

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants