-
Notifications
You must be signed in to change notification settings - Fork 191
bump React from 18 to 19 #690
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough本次变更将多处 React refs 显式初始化为 Changes
Sequence Diagram(s)(此变更仅限类型与依赖调整,未引入新的控制流或交互,无需序列图) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (1)tests/ref.test.tsx (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @li-jia-nan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on a significant upgrade of the project's React dependency from version 18 to 19. The changes involve updating the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Code Review
This pull request upgrades React from version 18 to 19. The changes primarily involve updating dependencies in package.json
and modifying useRef
calls to align with React 19's new requirements, such as initializing DOM refs with null
. Most of the changes are correct and necessary for the upgrade. However, I found a critical issue in src/hooks/useEvent.ts
where a useRef
call was updated incorrectly, leading to a read-only ref being mutated. My review includes a specific suggestion to fix this typing issue.
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)
tests/ref-19.test.tsx (1)
42-42
: 建议使用更具体的类型而非any
。当前使用
React.cloneElement<any>
削弱了类型安全性。考虑使用更具体的类型,例如:- {React.cloneElement<any>(children, { ref: mergedRef })} + {React.cloneElement<React.ReactElement>(children, { ref: mergedRef })}不过,如果 React 19 的类型定义导致更具体的类型出现冲突,当前的
<any>
用法在测试场景中是可以接受的。tests/toArray-19.test.tsx (1)
5-5
: 考虑使用更具体的基础类型。当前使用
React.PropsWithChildren<any>
中的any
可以进一步具体化。由于该组件不需要额外的 props,可以使用空对象类型:-class UL extends React.Component<React.PropsWithChildren<any>> { +class UL extends React.Component<React.PropsWithChildren<{}>> {或者使用
Record<string, never>
来明确表示没有额外属性:-class UL extends React.Component<React.PropsWithChildren<any>> { +class UL extends React.Component<React.PropsWithChildren<Record<string, never>>> {不过在测试场景中,当前的实现也是可以接受的。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.json
(2 hunks)tests/ref-19.test.tsx
(1 hunks)tests/toArray-19.test.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test / react component workflow
- GitHub Check: test / react component workflow
🔇 Additional comments (1)
package.json (1)
42-42
: 依赖升级正确且一致。所有 React 相关的依赖和类型定义都已正确升级到 v19.2.0,保持了版本一致性。peerDependencies 保持
>=18.0.0
也是合理的,确保了对 React 18 和 19 的兼容性。Also applies to: 50-52, 67-68
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #690 +/- ##
==========================================
- Coverage 90.28% 88.70% -1.59%
==========================================
Files 37 37
Lines 885 885
Branches 301 301
==========================================
- Hits 799 785 -14
- Misses 84 97 +13
- Partials 2 3 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit