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

Created on 8 May 2020  路  2Comments  路  Source: facebook/react

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?!

Unconfirmed

Most helpful comment

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 :smile:

All 2 comments

I think it's related to the recent change to prefix createRoot with unstable https://github.com/facebook/react/blob/master/packages/react-dom/index.experimental.js#L22

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 :smile:

Was this page helpful?
0 / 5 - 0 ratings