-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use reactRender from react-dom/client in React 19 #608
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
演练此次更改主要针对 React 渲染和卸载机制进行了更新,以适配 React 18 的新 API。修改包括更新导入语句、引入新的渲染和卸载逻辑,并确保与旧版本 React 的兼容性。主要变更涉及使用 变更
序列图sequenceDiagram
participant App as 应用程序
participant Render as 渲染模块
participant ReactDOM as ReactDOM
alt React 版本 >= 18
App->>Render: 调用渲染
Render->>ReactDOM: 使用 createRoot
ReactDOM-->>Render: 创建根容器
else React 版本 < 18
App->>Render: 调用渲染
Render->>ReactDOM: 使用传统渲染方法
ReactDOM-->>Render: 渲染完成
end
目标评估
可能相关的 PR
诗歌
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/React/render.ts (2)
Line range hint
14-18
: 在获取主版本时的异常处理有助于兼容旧版本或缺失版本信息的情况。
使用 try/catch 捕获并忽略错误是一个简洁方法。但需要确保后续逻辑不会在版本号无法获取时发生意料之外的问题。
Line range hint
30-37
: toggleWarning 函数对内部使用的警告标志做了按需切换,逻辑清晰。
此处可考虑在生产环境下跳过该逻辑,以减少不必要的副作用。同时不要在意外场景下长时间保持该标志为 true。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/React/render.ts
(1 hunks)
🔇 Additional comments (2)
src/React/render.ts (2)
2-2
: 切换至 React 18 的 'react-dom/client' 导入看起来不错。
使用新版 API 有助于支持 createRoot 等特性,同时与 React 18 的渲染流程保持一致。但需确保项目的 react 版本在 18 及以上。
Line range hint 60-68
: modernUnmount 中异步延迟卸载能有效避免 React 18 的告警,但要注意被延迟卸载的组件行为。
目前做了 Promise.resolve().then(...) 的延迟调用,不会阻塞线程,能够在 React 18 中避免同步警告。若后续组件在卸载前还有其他异步操控需求,需额外保证逻辑有序执行。
closing as it's fixed in v5.44.2...v5.44.3 |
fix #550
Summary by CodeRabbit
新特性
文档