From 3521e5698fdf7bb9b34e491e077d9b887cac990b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 Jan 2023 16:42:18 -0600 Subject: [PATCH] Switch to React 18's createRoot API https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis --- app/soapbox/main.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/soapbox/main.tsx b/app/soapbox/main.tsx index 41dd3a233..671e7a752 100644 --- a/app/soapbox/main.tsx +++ b/app/soapbox/main.tsx @@ -3,7 +3,7 @@ import './precheck'; import * as OfflinePluginRuntime from '@lcdp/offline-plugin/runtime'; import React from 'react'; -import ReactDOM from 'react-dom'; +import { createRoot } from 'react-dom/client'; import { defineMessages } from 'react-intl'; import { setSwUpdating } from 'soapbox/actions/sw'; @@ -34,9 +34,10 @@ function main() { } ready(() => { - const mountNode = document.getElementById('soapbox') as HTMLElement; + const container = document.getElementById('soapbox') as HTMLElement; + const root = createRoot(container); - ReactDOM.render(, mountNode); + root.render(); if (BuildConfig.NODE_ENV === 'production') { // avoid offline in dev mode because it's harder to debug