Update ReactDOM render to use createRoot (#148)

react 18 new API
This commit is contained in:
Elisha Nuchi
2023-03-12 01:04:49 -05:00
committed by GitHub
parent 8265933d4b
commit 7a26c690e1
4 changed files with 16 additions and 8 deletions
+4 -2
View File
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client';
import { serverFunctions } from '../src/client/utils/serverFunctions.ts'; import { serverFunctions } from '../src/client/utils/serverFunctions.ts';
const { FILENAME, PORT } = process.env; const { FILENAME, PORT } = process.env;
@@ -58,4 +58,6 @@ const DevServer = () => {
); );
}; };
ReactDOM.render(<DevServer />, document.getElementById('index')); const container = document.getElementById('index');
const root = createRoot(container);
root.render(<DevServer />);
+4 -2
View File
@@ -1,7 +1,9 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client';
import SheetEditor from './components/SheetEditor'; import SheetEditor from './components/SheetEditor';
import './styles.css'; import './styles.css';
ReactDOM.render(<SheetEditor />, document.getElementById('index')); const container = document.getElementById('index');
const root = createRoot(container);
root.render(<SheetEditor />);
+4 -2
View File
@@ -1,7 +1,9 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client';
import SheetEditor from './components/SheetEditor'; import SheetEditor from './components/SheetEditor';
import './styles.css'; import './styles.css';
ReactDOM.render(<SheetEditor />, document.getElementById('index')); const container = document.getElementById('index');
const root = createRoot(container);
root.render(<SheetEditor />);
+4 -2
View File
@@ -1,5 +1,7 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client';
import About from './components/About'; import About from './components/About';
ReactDOM.render(<About />, document.getElementById('index')); const container = document.getElementById('index');
const root = createRoot(container);
root.render(<About />);