24 lines
609 B
TypeScript
24 lines
609 B
TypeScript
import React from 'react';
|
|
import ReactDOM from 'react-dom/client';
|
|
import App from './App';
|
|
|
|
const rootElement = document.getElementById('root');
|
|
if (!rootElement) {
|
|
throw new Error("Could not find root element to mount to");
|
|
}
|
|
|
|
// Use hydrateRoot when react-snap has pre-rendered HTML, createRoot for normal dev/fallback
|
|
if (rootElement.hasChildNodes()) {
|
|
ReactDOM.hydrateRoot(
|
|
rootElement,
|
|
<React.StrictMode>
|
|
<App />
|
|
</React.StrictMode>
|
|
);
|
|
} else {
|
|
ReactDOM.createRoot(rootElement).render(
|
|
<React.StrictMode>
|
|
<App />
|
|
</React.StrictMode>
|
|
);
|
|
} |