Skip to content

Commit b3b92b6

Browse files
authored
Upgrade react 18 to rc, drop prerelease warning (vercel#32619)
### Enhancement * Auto enable reactRoot API for react 18 since the legacy render in `react-dom` is dropped * Remove prelrease warning
1 parent e8408c7 commit b3b92b6

File tree

4 files changed

+24
-65
lines changed

4 files changed

+24
-65
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@
137137
"pretty-ms": "7.0.0",
138138
"random-seed": "0.3.0",
139139
"react": "17.0.2",
140-
"react-18": "npm:[email protected]beta-0cc724c77-20211125",
140+
"react-18": "npm:[email protected]rc.0",
141141
"react-dom": "17.0.2",
142-
"react-dom-18": "npm:[email protected]beta-0cc724c77-20211125",
142+
"react-dom-18": "npm:[email protected]rc.0",
143143
"react-ssr-prepass": "1.0.8",
144144
"release": "6.3.0",
145145
"request-promise-core": "1.1.2",

packages/next/build/webpack-config.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,15 @@ export default async function getBaseWebpackConfig(
346346
Boolean(reactDomVersion) &&
347347
(semver.gte(reactDomVersion!, '18.0.0') ||
348348
semver.coerce(reactDomVersion)?.version === '18.0.0')
349-
const hasReactPrerelease =
350-
(Boolean(reactDomVersion) && semver.prerelease(reactDomVersion!) != null) ||
351-
isReactExperimental
352349

353350
const hasReactRoot: boolean =
354351
config.experimental.reactRoot || hasReact18 || isReactExperimental
355352

353+
// Make sure reactRoot is enabled when react 18 is detected
354+
if (hasReactRoot) {
355+
config.experimental.reactRoot = true
356+
}
357+
356358
// Only inform during one of the builds
357359
if (
358360
!isServer &&
@@ -381,19 +383,6 @@ export default async function getBaseWebpackConfig(
381383
hasConcurrentFeatures && !!config.experimental.serverComponents
382384
const targetWeb = webServerRuntime || !isServer
383385

384-
// Only inform during one of the builds
385-
if (!isServer) {
386-
if (hasReactRoot) {
387-
Log.info('Using the createRoot API for React')
388-
}
389-
if (hasReactPrerelease) {
390-
Log.warn(
391-
`You are using an unsupported prerelease of 'react-dom' which may cause ` +
392-
`unexpected or broken application behavior. Continue at your own risk.`
393-
)
394-
}
395-
}
396-
397386
if (webServerRuntime) {
398387
Log.warn(
399388
'You are using the experimental Edge Runtime with `concurrentFeatures`.'

test/integration/react-18/test/index.test.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
2424
const dynamicHello = new File(join(appDir, 'components/dynamic-hello.js'))
2525
const unwrappedPage = new File(join(appDir, 'pages/suspense/unwrapped.js'))
2626

27-
const UNSUPPORTED_PRERELEASE =
28-
"You are using an unsupported prerelease of 'react-dom'"
2927
const USING_CREATE_ROOT = 'Using the createRoot API for React'
3028

3129
async function getBuildOutput(dir) {
@@ -70,13 +68,11 @@ describe('React 18 Support', () => {
7068
test('supported version of react in dev', async () => {
7169
const output = await getDevOutput(appDir)
7270
expect(output).not.toMatch(USING_CREATE_ROOT)
73-
expect(output).not.toMatch(UNSUPPORTED_PRERELEASE)
7471
})
7572

7673
test('supported version of react in build', async () => {
7774
const output = await getBuildOutput(appDir)
7875
expect(output).not.toMatch(USING_CREATE_ROOT)
79-
expect(output).not.toMatch(UNSUPPORTED_PRERELEASE)
8076
})
8177

8278
test('suspense is not allowed in blocking rendering mode (prod)', async () => {
@@ -90,32 +86,6 @@ describe('React 18 Support', () => {
9086
)
9187
})
9288
})
93-
94-
describe('Use react-dom 18 prerelease', () => {
95-
beforeAll(async () => {
96-
const reactDomPkgPath = join(
97-
appDir,
98-
'node_modules/react-dom/package.json'
99-
)
100-
await fs.outputJson(reactDomPkgPath, {
101-
name: 'react-dom',
102-
version: '18.0.0-alpha-c76e4dbbc-20210722',
103-
})
104-
})
105-
afterAll(async () => await fs.remove(join(appDir, 'node_modules')))
106-
107-
test('prerelease version of react in dev', async () => {
108-
const output = await getDevOutput(appDir)
109-
expect(output).toMatch(USING_CREATE_ROOT)
110-
expect(output).toMatch(UNSUPPORTED_PRERELEASE)
111-
})
112-
113-
test('prerelease version of react in build', async () => {
114-
const output = await getBuildOutput(appDir)
115-
expect(output).toMatch(USING_CREATE_ROOT)
116-
expect(output).toMatch(UNSUPPORTED_PRERELEASE)
117-
})
118-
})
11989
})
12090

12191
describe('Basics', () => {

yarn.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16482,22 +16482,22 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7, rc@^1.2.8:
1648216482
minimist "^1.2.0"
1648316483
strip-json-comments "~2.0.1"
1648416484

16485-
"react-18@npm:[email protected]beta-0cc724c77-20211125":
16486-
version "18.0.0-beta-0cc724c77-20211125"
16487-
resolved "https://registry.yarnpkg.com/react/-/react-18.0.0-beta-0cc724c77-20211125.tgz#e0050eb21c398902c5c0f7da9f4b8b52b8effd66"
16488-
integrity sha512-odsMe3EsqWSZy/ksPiSGuUcs41iAQQGEcws0565jsSQskJMLm7NOZ51AAoClIj8kZI4i3uHe/o22tZff9EsGnA==
16485+
"react-18@npm:[email protected]rc.0":
16486+
version "18.0.0-rc.0"
16487+
resolved "https://registry.yarnpkg.com/react/-/react-18.0.0-rc.0.tgz#60bfcf1edd0b35fbeeeca852515c6cc2ce06a6eb"
16488+
integrity sha512-PawosMBgF8k5Nlc3++ibzjFqPvo1XKv80MNtVYqz3abHHB2w3IpU65sSdSmBd2ooCwVhcp9b1vkx/twqhakNtA==
1648916489
dependencies:
1649016490
loose-envify "^1.1.0"
1649116491
object-assign "^4.1.1"
1649216492

16493-
"react-dom-18@npm:[email protected]beta-0cc724c77-20211125":
16494-
version "18.0.0-beta-0cc724c77-20211125"
16495-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0-beta-0cc724c77-20211125.tgz#7f7ac2a37e69c16cb97a42a52ffe24e80ab02027"
16496-
integrity sha512-SzWHSBjNIzn43jB+IeQhqgQE3zLJTFMv5KzvSFttKC9QSBS11vuYLdELjpiUNAMaAOmY4qmcnLEQvmKNwGK5fQ==
16493+
"react-dom-18@npm:[email protected]rc.0":
16494+
version "18.0.0-rc.0"
16495+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0-rc.0.tgz#aa07044bdd6399ff94c664b2985e2e25948fbf3e"
16496+
integrity sha512-tdD1n0svTndHBQvVAq/f2Kx7FgQ30CpSLp87/neQKAHPW5WtdgW1sBSwmFAcMQOrmstTuP0M+zRlH86f9kMX/A==
1649716497
dependencies:
1649816498
loose-envify "^1.1.0"
1649916499
object-assign "^4.1.1"
16500-
scheduler "0.21.0-beta-0cc724c77-20211125"
16500+
scheduler "^0.21.0-rc.0"
1650116501

1650216502
1650316503
version "17.0.2"
@@ -17464,14 +17464,6 @@ saxes@^5.0.1:
1746417464
dependencies:
1746517465
xmlchars "^2.2.0"
1746617466

17467-
17468-
version "0.21.0-beta-0cc724c77-20211125"
17469-
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0-beta-0cc724c77-20211125.tgz#2251f681a2e4e24bb0ad42909ce6dae253a39925"
17470-
integrity sha512-ZqjVAbosIfddFmNMdlJO/F0kr33qdgTGlLFCgIXsNIz/SjNq0Hn+lIaYtaIQPhZRFPwIgYOt+ssui0zZJ58rVg==
17471-
dependencies:
17472-
loose-envify "^1.1.0"
17473-
object-assign "^4.1.1"
17474-
1747517467
scheduler@^0.20.2:
1747617468
version "0.20.2"
1747717469
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91"
@@ -17480,6 +17472,14 @@ scheduler@^0.20.2:
1748017472
loose-envify "^1.1.0"
1748117473
object-assign "^4.1.1"
1748217474

17475+
scheduler@^0.21.0-rc.0:
17476+
version "0.21.0-rc.0-next-f2a59df48-20211208"
17477+
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0-rc.0-next-f2a59df48-20211208.tgz#54e18e1d360194fd54b47a00616e46403fcabdf1"
17478+
integrity sha512-x0oLd3YIih9GHqWTaFYejVe6Au+4TadOWZciAq8m4+Fuo5qCi4/3M35a9irVSIP3+qcg/fCqHKJETT9G0ejD1A==
17479+
dependencies:
17480+
loose-envify "^1.1.0"
17481+
object-assign "^4.1.1"
17482+
1748317483
"schema-utils2@npm:[email protected]":
1748417484
version "2.7.1"
1748517485
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"

0 commit comments

Comments
 (0)