Bug: Typeerror: ReactDOM.createRoot(container) is not a function
See original GitHub issueReactDOM.createRoot is not a function
React & ReactDOM version:^0.0.0-experimental-33c3af284
Steps To Reproduce
- npx create-react-app my-app --template typescript
- cd my-app && yarn upgrade react@experimental react-dom@experimental
- refrence types in react-app-env.d.ts
/// <reference types="react-scripts" /> /// <reference types="react/experimental" /> /// <reference types="react-dom/experimental" />
Additional Info: OS: Windows 10 Browser: Chrome
The current behavior
no ui renders instead following error occurs:-
TypeError: react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.createRoot is not a function
The expected behavior
Everything should work fine i guess?!
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
I can't use createRoot function in react-dom/client
If this code is executed, the error happens like following. Could not find a declaration file for module 'react-dom/client'. 'E:/Workspace/React ...
Read more >ReactDOM.createRoot ReactDOM.render - DEV Community
We have to pass the container to render function every time we want to explicitly ... throw Error('Target container is not a DOM...
Read more >ReactDOMClient – React
createRoot () controls the contents of the container node you pass in. Any existing DOM elements inside are replaced when render is called....
Read more >You are importing createRoot from 'react-dom' which is not ...
The error "You are importing createRoot from 'react-dom' which is not supported" occurs when we import the `createRoot` function from `react-dom`.
Read more >Solved - createRoot() Target container is not a DOM element
This error occurs commonly due to either passing in the wrong "id" to the "document.getElelementById()" method or by calling the React ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bvaughn
ReactDOM.unstable_createRoot
is still giving me the same error.I don’t think you shared an actual repro, @raghav0622. The GitHub repo you linked to uses
ReactDOM.render
.@nihgwu is right though that we recently added an “unstable_” prefix to several unreleased APIs, including
createRoot
. You’d need to useReactDOM.unstable_createRoot
for now 😄