8000 refactor: Update rc-util ref func to resolve React 19 warning by zombieJ · Pull Request #24 · react-component/portal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Feb 24, 2025

Conversation

zombieJ
Copy link
Member
@zombieJ zombieJ commented Feb 24, 2025

Summary by CodeRabbit

  • 文档

    • 更新了使用说明,确保示例与最新推荐的组件调用方式保持一致。
  • Chores

    • 升级包版本至 2.0.0,并调整了构建与测试脚本。
    • 更新和替换部分依赖,提高了对新版 React 和 Node.js 的兼容性。

Copy link
coderabbitai bot commented Feb 24, 2025

Walkthrough

本次变更主要更新了项目中多个文件的模块导入路径,统一将部分从 "rc-" 前缀的依赖替换为 "@rc-component/"。此外,还对 package.json 文件进行了版本升级和脚本、依赖项的调整,同时对部分组件中子节点引用获取方式做了细微修改,测试代码中也相应调整了名称和监控逻辑。

Changes

文件路径 改动描述
README.md 更新导入语句,从 rc-portal 替换为 @rc-component/portal,示例代码未变。
package.json 升级版本到 2.0.0;修改 prepublish 和测试脚本;更新、添加、移除依赖和 peerDependencies,以及调整 Node.js engines 要求。
src/Portal.tsx 更新导入语句由 rc-util 改为 @rc-component/util;修改子节点的引用获取逻辑,由解构方式替换为调用 getNodeRef
src/useDom.tsx, src/useScrollLocker.tsx 修改导入路径,将 rc-util 相关的路径更新为 @rc-component/util
tests/index.test.tsx, tests/webkit.test.tsx 更新导入和 Jest mock 模块路径至 @rc-component/util;重命名测试用例及调整错误检测逻辑;移除无用的导入。

Sequence Diagram(s)

sequenceDiagram
    participant Demo
    participant Portal
    participant Util
    Demo->>Portal: 传入子组件(child)与 ref
    Portal->>Util: 调用 getNodeRef(child)
    Util-->>Portal: 返回子组件的引用
    Portal->>Demo: 渲染子组件
Loading

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/useDom.tsx

Oops! 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:

npm install eslint-plugin-react@latest --save-dev

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.tsx

Oops! 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:

npm install eslint-plugin-react@latest --save-dev

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.tsx

Oops! 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:

npm install eslint-plugin-react@latest --save-dev

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.

  • 2 others
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
github-actions bot commented Feb 24, 2025

😭 Deploy PR Preview b11b982 failed. Build logs

🤖 By surge-preview

Copy link

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@rc-component/father-plugin@2.0.3 🔁 npm/@rc-component/father-plugin@1.1.0 None +4 121 kB zombiej
npm/@rc-component/np@1.0.3 Transitive: environment, eval, filesystem, shell, unsafe +143 16 MB zombiej
npm/@rc-component/util@1.2.1 environment +1 202 kB zombiej
npm/rc-test@7.1.2 environment, filesystem Transitive: eval, shell, unsafe +137 16.6 MB zombiej

🚮 Removed packages: npm/cheerio@1.0.0-rc.12

View full report↗︎

Copy link
codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.27%. Comparing base (a518b19) to head (b11b982).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between a518b19 and b11b982.

📒 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 警告:

  1. 正确使用 console.error spy 来验证没有警告
  2. 适当的清理了 spy
  3. 测试名称更新反映了新的测试目的
tests/webkit.test.tsx (1)

14-22: Mock 路径更新正确

成功更新了 mock 路径以匹配新的 @rc-component/util 包:

  1. useLayoutEffect mock 路径已更新
  2. 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",这能帮助利用新版本的性能和特性。建议在所有部署和开发环境中验证这一版本要求。

@zombieJ zombieJ merged commit 9c2d3e1 into master Feb 24, 2025
11 checks passed
@zombieJ zombieJ deleted the bump-father-plugin branch February 24, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0