xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

React 18 errors All In One

React 18 errors All In One

errors

Module '"react-dom"' has no exported member 'createRoot'.ts(2305)

image

// ❌
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

image

image

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, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(9)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 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
点击右上角即可分享
微信分享提示