React 18 errors All In One
React 18 errors All In One
errors
Module '"react-dom"' has no exported member 'createRoot'.ts(2305)
// ❌
import { createRoot } from "react-dom";
solutions
// ✅
import { createRoot } from "react-dom/client";
// Before
import { render } from 'react-dom';
const container = document.getElementById('app');
render(<App tab="home" />, container);
// After
import { createRoot } from 'react-dom/client';
const container = document.getElementById('app');
const root = createRoot(container); // createRoot(container!) if you use TypeScript
root.render(<App tab="home" />);
https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
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
React 18
introduces a new root API which provides better ergonomics for managing roots.
The new root API
also enables the new concurrent renderer, which allows you to opt-into concurrent features.
demos
# react-dom
$ npm install react react-dom
https://www.npmjs.com/package/react-dom
react blogs
https://react.dev/blog/2024/05/22/react-conf-2024-recap
https://www.youtube.com/watch?v=T8TZQ6k4SLE
React 19
RC
https://react.dev/blog/2024/04/25/react-19
React v18.0
https://react.dev/blog/2022/03/29/react-v18
refs
https://medium.com/fortum-tech/tips-tricks-upgrading-to-react-18-ece2fc726242
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/18450855
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2023-10-08 Vitest All In One
2023-10-08 Linux file system All In One
2023-10-08 MongoDB and Mongoose in Action All In One
2022-10-08 LeetCode 字符串相乘算法题解 All In One
2022-10-08 Game Development Essential Terms All In One
2022-10-08 河南美食-阿利茄汁面 All In One
2021-10-08 Web API appendChild bugs All In One