-
Notifications
You must be signed in to change notification settings - Fork 425
feat(ui): replace sync update with deferred promise pattern #7586
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
feat(ui): replace sync update with deferred promise pattern #7586
Conversation
Replace the flushSync call in BaseRouter's baseNavigate with a deferred promise pattern. This achieves the same guarantee (re-render completes before returning control to the caller) without the performance penalty of synchronously flushing React's update queue. The new approach stores the resolve function in state alongside the new route parts, and an effect resolves the promise after React commits the state update.
⚠️ No Changeset found
Latest commit: c418183
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary
Replaces the
flushSynccall inBaseRouter'sbaseNavigatewith a deferred promise pattern.Problem
The current implementation uses
flushSyncto guarantee the re-render happens before returning control to the caller. While this works,flushSynchas performance implications:Solution
Use a deferred promise pattern instead:
Benefits
flushSyncperformance penalty