Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Assume a recent react@experimental if reactRoot is set (vercel#25496
Browse files Browse the repository at this point in the history
)
  • Loading branch information
devknoll committed May 28, 2021
1 parent cc2b4c1 commit 8f6f62b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 5 additions & 4 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,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

0 comments on commit 8f6f62b

Please sign in to comment.