Skip to content

Commit 5b31055

Browse files
committed
Update templates to use createRoot
1 parent 67b4868 commit 5b31055

File tree

2 files changed

+10
-8
lines changed
  • packages

2 files changed

+10
-8
lines changed

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

Lines 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

Lines 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

0 commit comments

Comments
 (0)