-
Notifications
You must be signed in to change notification settings - Fork 19
refactor: Update rc-util ref func to resolve React 19 warning #2 8000 4
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
Conversation
Walkthrough本次变更主要更新了项目中多个文件的模块导入路径,统一将部分从 "rc-" 前缀的依赖替换为 "@rc-component/"。此外,还对 package.json 文件进行了版本升级和脚本、依赖项的调整,同时对部分组件中子节点引用获取方式做了细微修改,测试代码中也相应调整了名称和监控逻辑。 Changes
Sequence Diagram(s)sequenceDiagram
participant Demo
participant Portal
participant Util
Demo->>Portal: 传入子组件(child)与 ref
Portal->>Util: 调用 getNodeRef(child)
Util-->>Portal: 返回子组件的引用
Portal->>Demo: 渲染子组件
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
src/useDom.tsxOops! Something went wrong! :( ESLint: 7.32.0 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs+fabric@3.0.0/node_modules/@umijs/fabric/dist/eslint.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. src/useScrollLocker.tsxOops! Something went wrong! :( ESLint: 7.32.0 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs+fabric@3.0.0/node_modules/@umijs/fabric/dist/eslint.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. src/Portal.tsxOops! Something went wrong! :( ESLint: 7.32.0 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs+fabric@3.0.0/node_modules/@umijs/fabric/dist/eslint.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
✨ Finishing Touches
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 (
|
😭 Deploy PR Preview b11b982 failed. Build logs 🤖 By surge-preview |
New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/cheerio@1.0.0-rc.12 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #24 +/- ##
==========================================
+ Coverage 93.10% 93.27% +0.17%
==========================================
Files 6 6
Lines 116 119 +3
Branches 41 44 +3
==========================================
+ Hits 108 111 +3
Misses 8 8 ☔ View full report in Codecov by Sentry. |
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 (1)
package.json (1)
41-43
: 测试脚本更新: 替换 umi-test 为 rc-test
test:client 和 test:server 脚本均已由 umi-test 更换为 rc-test,以适配 React 19。注意到 test:client 中有重复的 --testPathIgnorePatterns 参数,建议核查是否需要保留重复配置。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
README.md
(1 hunks)package.json
(3 hunks)src/Portal.tsx
(2 hunks)src/useDom.tsx
(1 hunks)src/useScrollLocker.tsx
(1 hunks)tests/index.test.tsx
(4 hunks)tests/webkit.test.tsx
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- src/useDom.tsx
- src/useScrollLocker.tsx
🔇 Additional comments (11)
src/Portal.tsx (2)
1-7
: 导入路径更新正确成功将依赖从 rc-util 迁移到 @rc-component/util,保持了一致性。
115-117
: 改进了 ref 处理逻辑以支持 React 19使用
getNodeRef
替代直接解构获取 ref,这种方式更加稳健,可以避免 React 19 中的警告。tests/index.test.tsx (1)
213-229
: 测试用例更新恰当测试用例已更新为检查 React 19 的 ref 警告:
- 正确使用
console.error
spy 来验证没有警告- 适当的清理了 spy
- 测试名称更新反映了新的测试目的
tests/webkit.test.tsx (1)
14-22
: Mock 路径更新正确成功更新了 mock 路径以匹配新的 @rc-component/util 包:
- useLayoutEffect mock 路径已更新
- getScrollBarSize mock 路径已更新
README.md (1)
35-35
: 文档示例更新正确示例代码中的导入语句已更新为使用 @rc-component/portal。
package.json (6)
3-3
: 版本号更新: 从 1.1.2 升级到 2.0.0
此次版本号提升表明可能存在重大或破坏性改动,请确认变更详情在更新日志或文档中有适当说明。
36-37
: 脚本调整: 更新 prepare 和 prepublishOnly 脚本
在 prepare 脚本中使用了 "dumi setup",并在 prepublishOnly 脚本中由原先的 np 命令替换为 "rc-np"。请确认此改动与 CI/CD 流程及发布流程的兼容性。
47-48
: 依赖更新: 替换 rc-util 为 @rc-component/util
将原有的 "rc-util" 替换为 "@rc-component/util" 并指定版本 "^1.2.1",请确认所有导入路径和模块使用已同步更新。
51-69
: 开发依赖更新: 多个依赖项升级与调整
开发依赖中更新了:
- "@rc-component/father-plugin" 升级至 "^2.0.2"
- 新增 "@rc-component/np" 并指定版本 "^1.0.3"
- rc-test、react、react-dom 分别更新为 "^7.1.2" 和 "^19.0.0"
- 同时将 TypeScript 升级到 "^5.0.0"
请确认这些更新与项目整体兼容,同时验证 React 19 环境下的测试和编译无误。
72-73
: 对等依赖更新: React & React-Dom 版本要求
对等依赖中将 react 和 react-dom 的要求更新为 ">=18.0.0",确保与项目依赖的实际版本保持一致,请检查文档和示例配置是否也同步更新。
76-77
: 引擎要求更新: Node.js 版本提升至 >=12.x
将 Node.js 的最低版本要求更新为 ">=12.x",这能帮助利用新版本的性能和特性。建议在所有部署和开发环境中验证这一版本要求。
Summary by CodeRabbit
文档
Chores