You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级至React 18.2.0后已用createRoot仍提示需使用createRoot

升级React 18.2.0后已使用createRoot仍收到需改用createRoot的错误提示

已将项目升级至React 18.2.0,并且在index.js中已经采用ReactDOM.createRoot的方式渲染应用,但依然收到要求使用createRoot的错误提示。了解到2022年4月已有其他用户遇到相同问题,查阅React更新日志却未找到相关修复记录,想知道该问题是否已经解决。

项目依赖配置(package.json)

"react": "^18.2.0",
"react-color": "^2.19.3",
"react-cool-onclickoutside": "^1.6.2",
"react-csv": "^2.2.2",
"react-device-detect": "^1.17.0",
"react-dom": "^18.2.0",
"react-heap": "^0.1.3",
"react-id-generator": "^3.0.1",
"react-map-gl": "^6.1.14",
"react-map-gl-draw": "0.21.1",
"react-mapbox-gl-geocoder": "^1.1.0",
"react-mentions": "^4.4.7",
"react-phone-input-2": "^2.14.0",
"react-redux": "^7.2.3",
"react-router-dom": "^5.2.0",
"react-script-hook": "^1.5.0",
"react-scripts": "4.0.3",
"react-select": "^4.3.1",
"react-select-country-list": "^2.2.3",

index.js代码片段

import ReactDOM from 'react-dom/client';
...

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

内容的提问来源于Stack Exchange,提问作者bonum_cete

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 15:55:33