Browse Source

docs: migrate the example to React 18 (#5533)

Aakansha Doshi 2 năm trước cách đây
mục cha
commit
0a5da0269f

+ 8 - 7
src/packages/excalidraw/example/index.tsx

@@ -1,12 +1,13 @@
-import React from "react";
-import ReactDOM from "react-dom";
+import { StrictMode } from "react";
+import { createRoot } from "react-dom/client";
 
 import App from "./App";
 
-const rootElement = document.getElementById("root");
-ReactDOM.render(
-  <React.StrictMode>
+const rootElement = document.getElementById("root")!;
+const root = createRoot(rootElement);
+
+root.render(
+  <StrictMode>
     <App />
-  </React.StrictMode>,
-  rootElement,
+  </StrictMode>,
 );

+ 2 - 2
src/packages/excalidraw/example/public/index.html

@@ -17,8 +17,8 @@
   <body>
     <noscript> You need to enable JavaScript to run this app. </noscript>
     <div id="root"></div>
-    <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script>
-    <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script>
+    <script src="https://unpkg.com/react@18.2.0/umd/react.development.js"></script>
+    <script src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.development.js"></script>
 
     <!-- This is so that we use the bundled excalidraw.development.js file instead
     of the actual source code -->