Skip to content

Commit

Permalink
added root render
Browse files Browse the repository at this point in the history
  • Loading branch information
reedoooo committed May 4, 2024
1 parent 03bbfdb commit 8f6e099
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||============================== //

Expand All @@ -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) => {
Expand Down Expand Up @@ -49,7 +52,7 @@ const AppWrapper = () => {
);
};

ReactDOM.render(<AppWrapper />, domNode);
root.render(<AppWrapper />); // Use the root to render the AppWrapper.

if (process.env.NODE_ENV === 'production') {
register(); // Only register the service worker in production
Expand Down

0 comments on commit 8f6e099

Please sign in to comment.