Bug: Typeerror: ReactDOM.createRoot(container) is not a function

See original GitHub issue

ReactDOM.createRoot is not a function

React & ReactDOM version:^0.0.0-experimental-33c3af284

Steps To Reproduce

  1. npx create-react-app my-app --template typescript
  2. cd my-app && yarn upgrade react@experimental react-dom@experimental
  3. refrence types in react-app-env.d.ts /// <reference types="react-scripts" /> /// <reference types="react/experimental" /> /// <reference types="react-dom/experimental" />

Github Repo to reproduce

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 screencapture-localhost-3000-2020-05-08-08_20_18

The expected behavior

Everything should work fine i guess?!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

20reactions
AbrarShahriarcommented, Jan 25, 2021

@bvaughn ReactDOM.unstable_createRoot is still giving me the same error.

14reactions
bvaughncommented, May 8, 2020

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 use ReactDOM.unstable_createRoot for now 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found