You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to switch the rendering method according to the env flag. getting an error as: TypeError: Cannot read properties of undefined (reading '_internalRoot')
here is my conditional rendering code:
import { StrictMode } from "react";
import { createRoot, hydrateRoot } from "react-dom/client";
import App from "./App";
The error you're seeing suggests that container is undefined, which is causing the error when attempting to access _internalRoot. This could happen if the element with the ID of "root" doesn't exist in the HTML document.
you could try something like this, this would solve your issue
The second issue is that createRoot and hydrateRoot have different signatures but you're trying to use them in the same way. That's also incorrect. The second hydrateRoot argument is required but you are missing it and trying to render() later, which is not how it's supposed to be used. Please see the hydrateRoot documentation and examples.
Note that hydrateRoot is done in a single step because we're specifying which tree to hydrate it with. It doesn't need an additional render. However, createRoot needs a full render because it's initially empty.
I am trying to switch the rendering method according to the env flag. getting an error as:
TypeError: Cannot read properties of undefined (reading '_internalRoot')
here is my conditional rendering code:
Live Demo
The text was updated successfully, but these errors were encountered: