-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
🗺 Add flushSync
option
#11003
Comments
1 task
Closed by #11005 |
🤖 Hello there, We just published version Thanks! |
This comment was marked as duplicate.
This comment was marked as duplicate.
🤖 Hello there, We just published version Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, with
future.v7_startTransiton
enabled, all React Router internal state updates are wrapped inReact.startTransition
(per remix-run/remix#5763). This ensures that updates work properly with Suspense and other features.However, sometimes you need to do something synchronously so you can immediately set focus or scroll position or something related. Normally you would do this with
flushSync
:However, this doesn't work if you're using a React Router API such as
submit
because the internal update is wrapped instartTransition
which is inherently asynchronous:Therefore, we need a way to opt-out of
startTransition
, which we can do by giving them a way to opt-intoflushSync
:This will be a new option on
Link
/Form
/navigate
/submit
/fetcher.load
/fetcher.submit
. It's worth noting that this will impact all updates for that navigation/fetch but in reality the only one that is sort of useful to you is the first one since you'll likely be doing scrolling/focus setting right after that. You won't have a way to hook into the internal updates in the middle. I.e., when you submit you'll be able to do something right after theidle->submitting
update. But then eventualsubmitting->?loading
will not be in the same event loop so you will still ned to use an effect to do something after that update.The text was updated successfully, but these errors were encountered: