When creating an app using create-react-app
I get the following error when trying to use hydrate
instead of the default .render
. Here is the src/index.js
file's contents.
import React from 'react';
import ReactDOMServer from 'react-dom/client';
import './index.css';
import App from './App';
const root = ReactDOMServer.createRoot(document.getElementById('root'));
root.hydrate(
<React.StrictMode>
<App />
</React.StrictMode>
);
Running the above code npm start
produces the following error
Uncaught TypeError: root.hydrate is not a function
The error is not present if I change the .hydrate
back to .render
and I am not sure why this is happening.