Skip to content

update to @rc-component/virtual-list #310

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

li-jia-nan
Copy link
Member

@li-jia-nan li-jia-nan commented May 18, 2025

Summary by CodeRabbit

  • 新特性

    • 包名更改为 "@rc-component/virtual-list",版本重置为 1.0.0。
    • 依赖和 peerDependencies 升级,支持 React 18 及以上版本。
  • 修复与优化

    • 示例组件的 ref 类型声明更加精确,提升类型安全性。
    • 多处 React ref 初始化方式优化,提升类型一致性和健壮性。
    • 组件 displayName 只在非生产环境下设置,减少生产包体积。
  • 依赖调整

    • 移除旧依赖,新增并升级相关依赖以适配最新 React 生态。
  • 测试

    • 测试用例依赖路径更新,确保兼容新依赖结构。
  • 其他

    • 更新 .gitignore,忽略 pnpm-lock.yaml 文件。

Copy link

vercel bot commented May 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
virtual-list ❌ Failed (Inspect) May 18, 2025 8:36am

Copy link

coderabbitai bot commented May 18, 2025

Walkthrough

本次变更主要涉及依赖包的升级与迁移、类型注解的细化、部分导入路径的更新,以及对 React 相关组件的 Ref 类型进行明确指定。同时,部分开发和测试依赖也做了调整,.gitignore 文件新增了对 pnpm 锁文件的忽略规则。核心功能和控制流未发生实质性变化。

Changes

文件/路径分组 变更摘要
.gitignore 新增忽略 pnpm-lock.yaml 文件。
package.json 包名更改为 @rc-component/virtual-list,版本重置为 1.0.0,依赖与 peerDependencies 结构重组与升级。
examples/animate.tsx 导入路径迁移,Ref 类型由 any 明确为 CSSMotionRef,部分函数参数加括号,样式格式调整。
examples/basic.tsx MyItem 组件 Ref 类型由 any 明确为 HTMLSpanElement。
examples/height.tsx MyItem 组件 Ref 类型由 HTMLElement 明确为 HTMLSpanElement,函数参数加括号。
examples/nest.tsx MyItem 组件 Ref 类型由 any 明确为 HTMLDivElement。
examples/no-virtual.tsx MyItem 组件由 React.FC 改为 ForwardRefRenderFunction,Ref 类型明确为 HTMLSpanElement。
examples/switch.tsx MyItem 组件及 ForwardMyItem Ref 类型由 any/FC 明确为 HTMLSpanElement,listRef 初始化为 null。
src/Filler.tsx ResizeObserver 导入路径迁移,forwardRef 泛型类型明确,displayName 赋值仅在非生产环境下。
src/Item.tsx refFunc 参数类型明确为 HTMLElement,cloneElement 增加泛型 any。
src/List.tsx 多处导入路径迁移,多个 useRef 明确初始化为 null,displayName 仅在非生产环境赋值。
src/ScrollBar.tsx raf 导入路径迁移,多个 ref 明确初始化为 null,delayHidden 函数格式调整。
src/hooks/useFrameWheel.ts raf 导入路径迁移。
src/hooks/useMobileTouchMove.ts useLayoutEffect 导入路径迁移。
src/hooks/useScrollDrag.ts raf 导入路径迁移。
src/hooks/useScrollTo.tsx raf、useLayoutEffect、warning 导入路径迁移,scrollRef 初始化为 null。
src/mock.tsx List 组件 forwardRef 泛型类型明确,displayName 仅在非生产环境赋值。
tests/scroll.test.js observerUtil、warning 导入路径迁移。
tests/scrollWidth.test.tsx observerUtil、domHook 导入路径迁移。

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant List
  participant Item
  participant Filler
  participant ScrollBar

  App->>List: 渲染并传递 Ref
  List->>Filler: 渲染并传递 Ref
  List->>ScrollBar: 渲染并传递 Ref
  List->>Item: 渲染并传递 Ref
  Note over List,Item: Ref 类型由 any/HTMLElement 明确为 HTML*Element
Loading

Poem

🐇
依赖升级新气象,
Ref 类型细又长。
路径迁移更清晰,
生产环境少点忙。
代码整洁如新装,
兔子欢跳庆改良!

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.

examples/height.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
    at Module._load (node:internal/modules/cjs/loader:1215:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
examples/animate.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
    at Module._load (node:internal/modules/cjs/loader:1215:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
examples/basic.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
    at Module._load (node:internal/modules/cjs/loader:1215:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
  • 14 others

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch update-version
  • Post Copyable Unit Tests in Comment

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.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​types/​react-dom@​18.3.7 ⏵ 19.1.510010072 -195100
Updated@​types/​react@​18.3.21 ⏵ 19.1.4100 +110078 +195100
Added@​rc-component/​resize-observer@​1.0.0791008781100
Added@​rc-component/​motion@​1.1.4811009985100
Added@​rc-component/​util@​1.2.110010010084100

View full report

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: 1

🧹 Nitpick comments (1)
src/hooks/useScrollTo.tsx (1)

40-40: 显式初始化 scrollRefnull 并完善类型
scrollRef 初始化为 null 以保证一致性,可进一步完善泛型以涵盖 null

- const scrollRef = React.useRef<number>(null);
+ const scrollRef = React.useRef<number | null>(null);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf79bff and 0b352c4.

📒 Files selected for processing (19)
  • .gitignore (1 hunks)
  • examples/animate.tsx (7 hunks)
  • examples/basic.tsx (1 hunks)
  • examples/height.tsx (2 hunks)
  • examples/nest.tsx (1 hunks)
  • examples/no-virtual.tsx (5 hunks)
  • examples/switch.tsx (4 hunks)
  • package.json (3 hunks)
  • src/Filler.tsx (4 hunks)
  • src/Item.tsx (1 hunks)
  • src/List.tsx (5 hunks)
  • src/ScrollBar.tsx (3 hunks)
  • src/hooks/useFrameWheel.ts (1 hunks)
  • src/hooks/useMobileTouchMove.ts (1 hunks)
  • src/hooks/useScrollDrag.ts (1 hunks)
  • src/hooks/useScrollTo.tsx (2 hunks)
  • src/mock.tsx (1 hunks)
  • tests/scroll.test.js (1 hunks)
  • tests/scrollWidth.test.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
examples/switch.tsx (1)
src/List.tsx (1)
  • ListRef (42-46)
src/List.tsx (1)
src/ScrollBar.tsx (1)
  • ScrollBarRef (24-26)
🪛 GitHub Actions: test
tests/scrollWidth.test.tsx

[error] 1-1: Test suite failed to run: ReferenceError: MessageChannel is not defined in react-dom-server.browser.development.js

tests/scroll.test.js

[error] 1-1: Test suite failed to run: ReferenceError: MessageChannel is not defined in react-dom-server.browser.development.js

🔇 Additional comments (47)
src/hooks/useFrameWheel.ts (1)

1-1: 更新 raf 导入路径
已将 rafrc-util/lib/raf 迁移至 @rc-component/util/lib/raf,与其他模块的导入路径保持一致,无需其他修改。

src/hooks/useScrollDrag.ts (1)

1-1: 同步 raf 导入路径
raf 已正确由 rc-util/lib/raf 更新为 @rc-component/util/lib/raf,符合依赖重构要求,逻辑未受影响。

src/hooks/useMobileTouchMove.ts (1)

1-1: 迁移 useLayoutEffect 导入来源
已将 useLayoutEffectrc-util/lib/hooks/useLayoutEffect 切换到 @rc-component/util/lib/hooks/useLayoutEffect,与整体依赖迁移保持一致。

.gitignore (1)

10-10: 新增 pnpm 锁文件忽略规则
已在 .gitignore 中添加 pnpm-lock.yaml,确保 pnpm 锁文件不被提交,符合多包管理工具兼容性需求。

src/hooks/useScrollTo.tsx (3)

3-3: 更新 raf 导入路径
raf 源自 @rc-component/util/lib/raf,已正确替换旧路径,相关调用无需调整。


6-6: 更新 useLayoutEffect 导入路径
useLayoutEffect 已切换至 @rc-component/util/lib/hooks/useLayoutEffect,与新依赖一致。


7-7: 更新 warning 导入路径
warning 已从新包 @rc-component/util 引入,导入路径无语法或类型问题。

src/Item.tsx (2)

9-9: 类型注解改进

参数 node 的类型现在明确为 HTMLElement,这提高了类型安全性,使函数参数类型更加明确。


12-12: 增加泛型类型参数

React.cloneElement 调用现在添加了 <any> 泛型参数,增强了类型安全性,同时保持了组件的灵活性。

tests/scroll.test.js (2)

4-4: 包路径更新

导入路径从 rc-resize-observer/lib/utils/observerUtil 更新为 @rc-component/resize-observer/lib/utils/observerUtil,与PR中的依赖升级保持一致。


5-5: 包路径更新

导入路径从 rc-util/lib/warning 更新为 @rc-component/util/lib/warning,与PR中的依赖升级保持一致。

tests/scrollWidth.test.tsx (2)

3-3: 包路径更新

导入路径从 rc-resize-observer/lib/utils/observerUtil 更新为 @rc-component/resize-observer/lib/utils/observerUtil,与PR中的依赖升级保持一致。


4-4: 包路径更新

导入路径从 rc-util/lib/test/domHook 更新为 @rc-component/util/lib/test/domHook,与PR中的依赖升级保持一致。

examples/nest.tsx (1)

16-16: 增强类型安全性

MyItem 组件的 ForwardRefRenderFunction 类型现在明确指定了 ref 类型为 HTMLDivElement 而不是泛型或 any,提高了类型安全性和代码可读性。

examples/basic.tsx (1)

9-9: 类型安全性改进

MyItem 组件的 ref 类型从 any 更改为明确的 HTMLSpanElement 类型,增强了类型安全性并提高了代码的可读性。这样可以确保转发的 ref 指向正确的 HTML 元素类型。

src/mock.tsx (2)

5-5: 明确指定泛型类型参数

React.forwardRef 调用明确指定了泛型类型参数 <ListRef, ListProps<any>>,而不是依赖隐式类型推断,这提高了代码的类型安全性和可读性。


11-13: 优化生产环境构建

只在非生产环境中设置 displayName 属性是一个很好的优化。这可以减小生产环境的包体积,因为 displayName 主要用于开发时的调试目的。

examples/height.tsx (2)

9-9: 类型安全性改进

MyItem 组件的 ref 类型从 any 更改为明确的 HTMLSpanElement 类型,增强了类型安全性并提高了代码的可读性。这与 examples/basic.tsx 文件中的类似更改保持一致。


53-53: 语法调整

在传递给 List 组件的内联函数中为参数 (item) 添加了括号。这是一个微小的语法调整,不影响功能,但使代码风格更一致。

src/ScrollBar.tsx (5)

2-2: 依赖包路径更新

rc-util/lib/raf 更新为 @rc-component/util/lib/raf,符合项目中依赖包迁移到 @rc-component 命名空间的整体变更。


52-53: ref 初始化改进

明确使用 null 初始化 React refs,而不是让它们保持未定义状态。这增强了类型安全性并使 ref 初始化更加一致。


57-57: ref 初始化改进

明确使用 null 初始化 visibleTimeoutRef,提高了代码的一致性和类型安全性。


60-62: 代码格式改进

为条件语句中的 return 添加了花括号,提高了代码的可读性和一致性。虽然这是一个样式上的改进,但不会改变逻辑。


125-128: ref 初始化改进

明确使用 null 初始化 enableScrollRangeRefenableOffsetRangeRef,保持了 ref 初始化的一致性和类型安全性。

examples/no-virtual.tsx (2)

10-10: 类型定义更加明确和安全

MyItem 组件的类型从简单的函数组件改为明确的 ForwardRefRenderFunction 类型,并指定了 ref 的类型为 HTMLSpanElement,这提高了代码的类型安全性和可读性。


53-53: 语法一致性改进

箭头函数参数从简写形式 item => ... 改为带括号形式 (item) => ...,提高了代码风格的一致性。

Also applies to: 67-67, 81-81, 94-94

src/Filler.tsx (4)

2-2: 依赖包更新

ResizeObserver 的导入源从 rc-resize-observer 更新为 @rc-component/resize-observer,符合项目依赖包的结构调整。


31-35: 类型安全性增强

React.forwardRef 增加了明确的泛型类型参数 <HTMLDivElement, FillerProps>,提高了组件的类型安全性。


73-73: className 表达式简化

简化了 className 的条件表达式,使代码更加简洁。


86-88: 生产环境优化

添加了对 displayName 的条件判断,仅在非生产环境下设置组件名称,这有助于减小生产环境的包体积。

src/List.tsx (3)

2-5: 依赖包路径更新

ResizeObserverPropsResizeObserveruseEventuseLayoutEffect 的导入路径从 rc-resize-observerrc-util 更新为 @rc-component/resize-observer@rc-component/util,与项目依赖结构调整保持一致。


151-153: Ref 初始化规范化

显式地将 React refs (componentRef, fillerInnerRef, containerRef, diffItemRef, verticalScrollBarRef, horizontalScrollBarRef) 初始化为 null,提高了类型安全性和一致性。这是一种良好的实践,可以确保在不同 React 版本下行为一致。

Also applies to: 193-193, 312-313


678-680: 生产环境优化

Filler.tsx 中的更改类似,添加了对 displayName 的条件判断,仅在非生产环境下设置组件名称,有助于减小生产环境的包体积。

examples/animate.tsx (5)

2-3: 依赖包更新

  1. CSSMotion 的导入源从 rc-animate/lib/CSSMotion 更新为 @rc-component/motion
  2. 显式导入 CSSMotionRef 类型以增强类型安全性
  3. useLayoutEffect 的导入路径从 rc-util/lib/hooks/useLayoutEffect 更新为 @rc-component/util/lib/hooks/useLayoutEffect

这些更改符合项目依赖包的结构调整。

Also applies to: 6-6


45-58: 类型定义优化

MyItem 组件的类型从简单的函数组件改为明确的 React.ForwardRefRenderFunction<CSSMotionRef, MyItemProps> 类型,指定了 ref 的类型为 CSSMotionRef,提高了类型安全性。


75-78: 箭头函数格式调整

调整了箭头函数的格式,使代码风格更加一致。

Also applies to: 146-147, 160-161, 167-168


136-136: Ref 初始化规范化

显式地将 listRef 初始化为 null,与 src/List.tsx 中的其他 ref 初始化保持一致,提高了类型安全性。


188-188: 样式格式调整

调整了样式对象的格式,没有功能上的变化。

examples/switch.tsx (5)

9-9: 改进了组件类型定义

MyItem 组件从泛型 React 函数组件改为明确的引用转发渲染函数,并指定了正确的 DOM 元素类型,提高了类型安全性。


26-26: 正确使用了 React.forwardRef 类型

使用 React.forwardRef<HTMLSpanElement, Item>(MyItem) 替代了之前可能使用 any 类型转换的做法,代码更加类型安全。


42-42: 正确初始化 React ref

使用 React.useRef<ListRef>(null) 明确初始化 ref 的值为 null,而不是让它保持 undefined。这是 React 的最佳实践,可以避免潜在的类型错误。


120-120: 样式对象格式改变

将多行样式对象简化为单行。这只是格式变化,不影响功能。


122-122: 移除了不必要的类型转换

移除了 (item as any) 类型转换,让 TypeScript 类型系统自然处理类型推断,代码更加简洁。

package.json (4)

2-3: 包名变更与版本重置

包名从 rc-virtual-list 更改为 @rc-component/virtual-list,版本号从 3.18.6 重置到 1.0.0。这表明这是一个重大更新或重组。

请确保在发布说明中明确说明此变更,以便用户了解需要更新导入路径。


39-43: 依赖项更新

依赖项已更新为使用 @rc-component 命名空间下的包,与包名变更保持一致。这看起来是 RC 组件生态系统更广泛重组的一部分。


47-56: 开发依赖更新

添加了 @rc-component/motion 依赖,并更新了 React 相关类型定义至更新的版本。这与整体依赖升级策略一致。


69-70: React 开发依赖大幅更新

React 和 ReactDOM 版本从固定的 16.14.0 更新到了灵活的 ^19.1.0,这是一个较大的版本跨度。请确保组件在这些新版本下正常工作且没有使用到仅在 React 19 中可用而在 React 18 中不可用的特性。

Comment on lines +73 to 76
"peerDependencies": {
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

对等依赖要求提高

将 React 和 ReactDOM 的最低版本要求从 >=16.9.0 提高到 >=18.0.0,这是一个破坏性变更。不再支持 React 16 和 17。

请确保:

  1. 在发布说明中明确标记这是一个破坏性变更
  2. 提供升级指南给仍在使用旧版本 React 的用户

🏁 Script executed:

#!/bin/bash
# 检查项目中是否有任何依赖于 React 16 或 17 特定功能的代码
rg "React\.version|react-dom.*16|react-dom.*17|\bReact\.render\b|\bfindDOMNode\b|\bunmountComponentAtNode\b" --type ts --type tsx

Length of output: 159


以下脚本将修正文件类型过滤,重新在 .ts.tsx 文件中搜索 React 16/17 特定 API:


🏁 Script executed:

#!/bin/bash
# 在 .ts 和 .tsx 文件中检查是否使用了 React 16/17 特定 API
rg "React\.version|react-dom.*16|react-dom.*17|\bReact\.render\b|\bfindDOMNode\b|\bunmountComponentAtNode\b" -g '*.ts' -g '*.tsx'

Length of output: 131


下面再在 .js.jsx 文件中执行相同的检查,确保覆盖所有源文件类型:


🏁 Script executed:

#!/bin/bash
# 在 .js 和 .jsx 文件中检查是否使用了 React 16/17 特定 API
rg "React\.version|react-dom.*16|react-dom.*17|\bReact\.render\b|\bfindDOMNode\b|\bunmountComponentAtNode\b" -g '*.js' -g '*.jsx'

Length of output: 131


请标注破坏性变更并提供升级指南

我已在 .ts.tsx.js.jsx 源文件中搜索 React 16/17 特定 API(如 React.renderfindDOMNodeunmountComponentAtNode 等),未发现相关用法,内部代码与 React 18 兼容。请在发布流程中补充以下内容:

  • 在发布说明(CHANGELOG/Release Notes)中明确标记将 React 和 ReactDOM 的最低版本从 >=16.9.0 提升至 >=18.0.0 属于破坏性变更
  • 提供升级指南,说明从 React 16/17 迁移到 React 18 的注意事项、常见问题及示例代码片段
🤖 Prompt for AI Agents
In package.json lines 73 to 76, the peerDependencies for React and ReactDOM have
been raised from >=16.9.0 to >=18.0.0, which is a breaking change. Update the
release notes or CHANGELOG to clearly mark this as a breaking change and add an
upgrade guide section that explains the migration from React 16/17 to React 18,
including key considerations, common issues, and example code snippets to assist
users in upgrading smoothly.

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