Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2eef1d0

Browse filesBrowse files
authored
Update templates to use React 18 createRoot (#12220)
1 parent 213b6a2 commit 2eef1d0
Copy full SHA for 2eef1d0

File tree

5 files changed

+81
-17
lines changed
Filter options

5 files changed

+81
-17
lines changed

‎package-lock.json

Copy file name to clipboardExpand all lines: package-lock.json
+67-5Lines changed: 67 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/cra-template-typescript/template.json

Copy file name to clipboardExpand all lines: packages/cra-template-typescript/template.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"@testing-library/user-event": "^13.2.1",
77
"@types/jest": "^27.0.1",
88
"@types/node": "^16.7.13",
9-
"@types/react": "^17.0.20",
10-
"@types/react-dom": "^17.0.9",
9+
"@types/react": "^18.0.0",
10+
"@types/react-dom": "^18.0.0",
1111
"typescript": "^4.4.2",
1212
"web-vitals": "^2.1.0"
1313
},

‎packages/cra-template-typescript/template/src/index.tsx

Copy file name to clipboardExpand all lines: packages/cra-template-typescript/template/src/index.tsx
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import ReactDOM from 'react-dom/client';
33
import './index.css';
44
import App from './App';
55
import reportWebVitals from './reportWebVitals';
66

7-
ReactDOM.render(
7+
const root = ReactDOM.createRoot(
8+
document.getElementById('root') as HTMLElement
9+
);
10+
root.render(
811
<React.StrictMode>
912
<App />
10-
</React.StrictMode>,
11-
document.getElementById('root')
13+
</React.StrictMode>
1214
);
1315

1416
// If you want to start measuring performance in your app, pass a function

‎packages/cra-template/template/src/index.js

Copy file name to clipboardExpand all lines: packages/cra-template/template/src/index.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import ReactDOM from 'react-dom/client';
33
import './index.css';
44
import App from './App';
55
import reportWebVitals from './reportWebVitals';
66

7-
ReactDOM.render(
7+
const root = ReactDOM.createRoot(document.getElementById('root'));
8+
root.render(
89
<React.StrictMode>
910
<App />
10-
</React.StrictMode>,
11-
document.getElementById('root')
11+
</React.StrictMode>
1212
);
1313

1414
// If you want to start measuring performance in your app, pass a function

‎packages/react-scripts/package.json

Copy file name to clipboardExpand all lines: packages/react-scripts/package.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
"workbox-webpack-plugin": "^6.4.1"
7878
},
7979
"devDependencies": {
80-
"react": "^17.0.2",
81-
"react-dom": "^17.0.2"
80+
"react": "^18.0.0",
81+
"react-dom": "^18.0.0"
8282
},
8383
"optionalDependencies": {
8484
"fsevents": "^2.3.2"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.