-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use flushSync to avoid render lag (fixes MBS-12424)
React v18 uses a new method of rendering that can be interrupted and doesn't block the page from performing other work. This can make updates appear laggy where we're trying to render many successive roots -- there is a noticeable delay between rendering each root where React yields its time. (In the case of MBS-12424, each "root" would be a track artist credit container.) This isn't really a problem with React, but a side effect of how we're gluing it into non-React code. Normally we wouldn't have so many roots. In order to make our haphazard way of rendering things into non-React pages appear more snappy, I'm wrapping all calls to `render` and `hydrateRoot` with `flushSync`, which causes all pending updates to the DOM to occur immediately. This keeps that behavior in line with how React v17 worked. Wrapping `hydrateRoot` in particular may affect the timing of when user scripts are allowed to interact with the page and avoid hydration errors.
- Loading branch information
Showing
8 changed files
with
126 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters