react18使用createRoot依旧报错

react18使用createRoot API后依旧报错怎么解? 求指教!

index.tsx文件

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

const container = document.getElementById('root');
const root = createRoot(container!); // createRoot(container!) if you use TypeScript
root.render(<App/>);

报错图如下

img

https://blog.csdn.net/ZLJ_999/article/details/124053111

import ReactDOM from 'react-dom/client';
import App from './App'
import './index.css'
 
const container = document.getElementById('root');
const root = ReactDOM.createRoot(container!); // createRoot(container!) if you use TypeScript
root.render(<App/>);

你代码看起来没问题呀。刷新下试试呢?是不是之前的报错,发出来的是修改后的代码