Просмотр исходного кода

Migrate `ReactDOM.render` to React 18+ using the `createRoot` API

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Mihaela Balutoiu 1 год назад
Родитель
Сommit
2e4e8f7ef4
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      src/index.tsx

+ 5 - 2
src/index.tsx

@@ -13,8 +13,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 import React from "react";
-import ReactDOM from "react-dom";
+import { createRoot } from "react-dom/client";
 
 import App from "./components/App";
 
-ReactDOM.render(<App />, document.getElementById("app"));
+const container = document.getElementById("app");
+
+const root = createRoot(container!);
+root.render(<App />);