index.jsで警告

ReactをCodeSandboxで勉強してたら、なにやら警告が・・・

import ReactDom from "react-dom";
import { App } from "./App";

ReactDom.render(<App />, document.getElementById("root"));
Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot

もうサポートされない書き方です。的な?

調べてみたら、

import { App } from "./App";
import { createRoot } from 'react-dom/client';

const container = document.getElementById('root');
const root = createRoot(container);
root.render(<App />);

これでエラーが出なくなりました。