I'd like to try out some of the new Concurrent Mode features in React 18. The official documentation, as well as several articles, claim that you just need to install react@experimental react-dom@experimental. I have done so but I am met with the following error:
Property 'unstable_createRoot' does not exist on type 'typeof import("C:/my-app/node_modules/@types/react-dom/index")'. TS2339
> 10 | ReactDOM.unstable_createRoot(document.getElementById("root")).render(<App />);
| ^
This is my trying to add this import to an existing project that is already working, not a new project from scratch
EDIT2: Here is my code:
import React from "react";
import ReactDOM from "react-dom";
import { App } from "./App";
ReactDOM.unstable_createRoot(document.getElementById("root")).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
That's a Typescript error/warning. (If you are not using Typescript, it's your editor using it behind the scenes.)
Your @types/react package doesn't have the unreleased experimental function you're trying to use.
See the comments in https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/experimental.d.ts#L2 to see how to bring the experimental bits into scope.