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

Assume a recent react@experimental if reactRoot is set #25496

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,11 @@ export default async function getBaseWebpackConfig(
const reactVersion = await getPackageVersion({ cwd: dir, name: 'react' })
const hasReactRefresh: boolean = dev && !isServer
const hasJsxRuntime: boolean =
Boolean(reactVersion) &&
// 17.0.0-rc.0 had a breaking change not compatible with Next.js, but was
// fixed in rc.1.
semver.gte(reactVersion!, '17.0.0-rc.1')
config.experimental.reactRoot ||
(Boolean(reactVersion) &&
// 17.0.0-rc.0 had a breaking change not compatible with Next.js, but was
// fixed in rc.1.
semver.gte(reactVersion!, '17.0.0-rc.1'))

const babelConfigFile = await [
'.babelrc',
Expand Down
6 changes: 1 addition & 5 deletions packages/next/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,7 @@ function renderReactElement(
const reactEl = fn(shouldHydrate ? markHydrateComplete : markRenderComplete)
if (process.env.__NEXT_REACT_ROOT) {
if (!reactRoot) {
const createRootName =
typeof (ReactDOM as any).unstable_createRoot === 'function'
? 'unstable_createRoot'
: 'createRoot'
reactRoot = (ReactDOM as any)[createRootName](domEl, {
reactRoot = (ReactDOM as any).createRoot(domEl, {
hydrate: shouldHydrate,
})
}
Expand Down