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

Allow developers to disable concurrent rendering (reactRoot: false) with React 18 #36419

Closed
wants to merge 1 commit into from

Commits on Apr 24, 2022

  1. Allow developers to disable concurrent rendering (reactRoot: false) w…

    …/React 18
    
    Currently any website that uses React 18 causes `shouldUseReactRoot()` to return true, which forces `config.experimental.reactRoot` to be true and enables concurrent rendering. There are several libraries--often those that buffer up CSS used during rendering and emit it before streaming the response to the client--that rely on React's rendering to be synchronous. While those libraries will eventually need to be updated to support streaming and Suspense in some cases, they work with React 18 otherwise.
    
    This commit lets websites disable concurrent features by explicitly setting `experimental.reactRoot = false` in next.config.js. If `experimental.reactRoot` is unspecified, then the existing default behavior still applies: `reactRoot` is true when using React 18+ or an experimental version and false otherwise. Production builds use the same resolved config object so future changes to this behavior will apply to both development and production.
    
    Tested in a sample website that relies on synchronous React rendering and uses React 18. When `experimental.reactRoot` is false, the site renders. When it's true or not defined, the site expectedly fails to render (as was the case before this commit). Ran `next build` to make sure that production builds honor the same logic.
    ide committed Apr 24, 2022
    Configuration menu
    Copy the full SHA
    0146c79 View commit details
    Browse the repository at this point in the history