From 14a1ff7fe4d4be6a26e384628c97506c1c378abd Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 27 Oct 2022 08:55:04 -0400 Subject: [PATCH 1/2] Switch to the React 18 createRoot API --- src/main.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index f8f3f0ae..f7aa6cad 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -20,8 +20,8 @@ limitations under the License. // dependency references. import "matrix-js-sdk/src/browser-index"; -import React from "react"; -import ReactDOM from "react-dom"; +import React, { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; import { createBrowserHistory } from "history"; import * as Sentry from "@sentry/react"; import { Integrations } from "@sentry/tracing"; @@ -39,6 +39,8 @@ initRageshake(); console.info(`matrix-video-chat ${import.meta.env.VITE_APP_VERSION || "dev"}`); +const root = createRoot(document.getElementById("root")!); + let fatalError: Error | null = null; if (!window.isSecureContext) { @@ -52,7 +54,7 @@ if (!window.isSecureContext) { } if (fatalError !== null) { - ReactDOM.render(<>fatalError.message, document.getElementById("root")); + root.render(fatalError.message); throw fatalError; // Stop the app early } @@ -147,9 +149,8 @@ i18n }, }); -ReactDOM.render( - +root.render( + - , - document.getElementById("root") + ); From 18b5ae9d4a499d814bc81b4ab43b2ac09fa2b982 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 27 Oct 2022 09:54:31 -0400 Subject: [PATCH 2/2] Fix lint --- .eslintrc.cjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 08a438ac..cb2ead0c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -28,6 +28,10 @@ module.exports = { "plugin:matrix-org/react", "prettier", ], + rules: { + // We're aiming to convert this code to strict mode + "@typescript-eslint/no-non-null-assertion": "off", + }, }, ], settings: {