From 8f6e0990c757c4eb294673f2186406ffb83eec42 Mon Sep 17 00:00:00 2001 From: Reed Vogt Date: Sat, 4 May 2024 10:36:31 -0700 Subject: [PATCH] added root render --- src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index febd60e..d08c6b2 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ import ReactDOM from 'react-dom'; import { BrowserRouter as Router } from 'react-router-dom'; import App from './App'; import { register, unregister } from './serviceWorker'; +import { createRoot } from 'react-dom/client'; // ==============================|| REACT DOM RENDER ||============================== // @@ -15,7 +16,9 @@ import { ParallaxProvider } from 'react-scroll-parallax'; import { HelmetMetaData } from 'data'; const domNode = document.getElementById('root'); +if (!domNode) throw new Error('Failed to find the root element'); +const root = createRoot(domNode); // Create a root. const AppWrapper = () => { const { theme } = useMode(); const errorHandler = (error, errorInfo) => { @@ -49,7 +52,7 @@ const AppWrapper = () => { ); }; -ReactDOM.render(, domNode); +root.render(); // Use the root to render the AppWrapper. if (process.env.NODE_ENV === 'production') { register(); // Only register the service worker in production