-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
refactor: rc-component/table #1219
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning Rate limit exceeded@li-jia-nan has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 5 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
概述演练这个拉取请求主要涉及从 变更
序列图sequenceDiagram
participant Dev as 开发者
participant Table as Table组件
participant Util as @rc-component/util
Dev->>Table: 配置表格
Table->>Util: 请求工具函数
Util-->>Table: 返回工具函数
Table->>Dev: 渲染表格
可能相关的 PR
建议的审阅者
诗歌
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: 1
🔭 Outside diff range comments (1)
src/Table.tsx (1)
Line range hint
530-532
: 修复可能的TypeError
错误在第 530-532 行,
scrollBodyRef.current
可能为 undefined,直接使用会导致TypeError
,正如流水线失败日志所示。建议在使用前添加空值检查。提供以下代码修改以修复此问题:
if (horizonScroll && scrollBodyRef.current) { - onInternalScroll({ - currentTarget: getDOM(scrollBodyRef.current) as HTMLElement, + const currentTarget = getDOM(scrollBodyRef.current) as HTMLElement; + if (currentTarget) { + onInternalScroll({ + currentTarget, scrollLeft: scrollBodyRef.current?.scrollLeft, }); + } } else { setPingedLeft(false); setPingedRight(false); }
🧹 Nitpick comments (3)
src/stickyScrollBar.tsx (3)
61-63
: 移除不必要的event.persist()
调用在
onMouseDown
函数中调用了event.persist()
,但在现代 React 中已不再需要。建议移除此调用。提供以下代码修改:
const onMouseDown = (event: React.MouseEvent) => { - event.persist(); refState.current.delta = event.pageX - scrollState.scrollLeft; refState.current.x = 0; setActive(true); event.preventDefault(); };
Line range hint
69-81
: 为onMouseMove
事件参数指定正确的类型
onMouseMove
函数的事件参数当前类型为any
,建议将其明确为MouseEvent
类型,增强类型安全性。提供以下代码修改:
- const onMouseMove = (event: any) => { + const onMouseMove = (event: MouseEvent) => { // ... }
79-81
: 简化left
计算表达式在计算
left
时,存在冗余运算,可以简化为:提供以下代码修改:
- let left = refState.current.x + event.pageX - refState.current.x - refState.current.delta; + let left = event.pageX - refState.current.delta;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (27)
docs/examples/animation.tsx
(1 hunks)package.json
(2 hunks)src/Cell/index.tsx
(1 hunks)src/Cell/useCellRender.ts
(1 hunks)src/FixedHolder/index.tsx
(1 hunks)src/Table.tsx
(2 hunks)src/VirtualTable/index.tsx
(1 hunks)src/hooks/useColumns/index.tsx
(1 hunks)src/hooks/useExpand.ts
(1 hunks)src/hooks/useFixedInfo.ts
(1 hunks)src/hooks/useRowInfo.tsx
(1 hunks)src/hooks/useSticky.ts
(1 hunks)src/stickyScrollBar.tsx
(6 hunks)src/utils/legacyUtil.ts
(1 hunks)src/utils/offsetUtil.ts
(1 hunks)tests/Deprecated.spec.jsx
(1 hunks)tests/ExpandRow.spec.jsx
(1 hunks)tests/FixedColumn-IE.spec.jsx
(1 hunks)tests/FixedColumn.spec.tsx
(1 hunks)tests/FixedHeader.spec.jsx
(1 hunks)tests/Hover.spec.tsx
(1 hunks)tests/Scroll.spec.jsx
(1 hunks)tests/Sticky.spec.jsx
(1 hunks)tests/Table.spec.jsx
(1 hunks)tests/Virtual.spec.tsx
(1 hunks)tests/refs.spec.tsx
(1 hunks)tests/setup.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (23)
- tests/FixedColumn.spec.tsx
- src/hooks/useColumns/index.tsx
- tests/Deprecated.spec.jsx
- src/Cell/index.tsx
- tests/Scroll.spec.jsx
- tests/Table.spec.jsx
- src/utils/legacyUtil.ts
- docs/examples/animation.tsx
- src/VirtualTable/index.tsx
- tests/refs.spec.tsx
- src/hooks/useExpand.ts
- src/FixedHolder/index.tsx
- src/hooks/useRowInfo.tsx
- tests/ExpandRow.spec.jsx
- src/hooks/useFixedInfo.ts
- tests/Hover.spec.tsx
- src/utils/offsetUtil.ts
- tests/FixedColumn-IE.spec.jsx
- tests/FixedHeader.spec.jsx
- src/hooks/useSticky.ts
- tests/Sticky.spec.jsx
- src/Cell/useCellRender.ts
- tests/Virtual.spec.tsx
🧰 Additional context used
🪛 GitHub Actions: ✅ test
src/Table.tsx
[error] 530-532: TypeError: Cannot read properties of undefined (reading 'width'). The error occurs when trying to access width property of scrollBodyRef.current or scrollBodyContainerRef which is undefined.
🔇 Additional comments (8)
src/Table.tsx (2)
30-36
: 新的导入语句正确更新导入语句已更新为使用新的
@rc-component/util
库,配置看起来正确。
78-78
: 验证getDOM
导入路径的正确性请确认从
@rc-component/util/lib/Dom/findDOMNode
导入的getDOM
函数路径是否正确,以确保模块路径和函数名准确无误。tests/setup.ts (1)
10-10
: 确认模拟模块的导入路径已将模拟的模块路径更改为
@rc-component/util/lib/getScrollBarSize
,请确认此路径和模块名称正确,确保测试能够正常运行。src/stickyScrollBar.tsx (4)
3-3
: 更新getScrollBarSize
的导入路径将
getScrollBarSize
的导入路径更新为@rc-component/util/lib/getScrollBarSize
,看起来正确。
7-7
: 更新raf
的导入路径将
raf
的导入路径更新为@rc-component/util/lib/raf
,看起来正确。
10-14
: 引入事件名称常量提高可读性将事件名称提取为常量,提高了代码的可读性和维护性。
141-149
: 确认使用document.body
添加事件监听器的适用性在添加和移除事件监听器时,使用了
document.body
。请确认在所有目标浏览器中,这样的使用方式都能正常工作。如有必要,考虑改为使用document
。package.json (1)
58-58
: 依赖包更新提醒将
rc-util
替换为@rc-component/util
是一个重要变更:
- 请确保新包
@rc-component/util
提供了与rc-util
相同的功能- 建议添加相关测试用例验证功能完整性
运行以下脚本检查依赖变更的影响:
✅ Verification successful
依赖迁移验证完成
经过代码扫描,确认:
- 已完全移除
rc-util
的引用@rc-component/util
的功能已被正确使用- 所有相关导入都已更新
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 检查是否还有遗留的 rc-util 导入 rg "from 'rc-util" || rg "from \"rc-util" # 检查是否所有 @rc-component/util 的导入都是有效的 rg "from '@rc-component/util" || rg "from \"@rc-component/util"Length of output: 3661
Summary by CodeRabbit
发行说明
新功能
rc-table
更改为@rc-component/table
依赖变更
rc-util
迁移到@rc-component/util
@rc-component/util
依赖,移除了rc-util
版本更新
7.50.2
更改为1.0.0
这些更改主要涉及包的重组和依赖管理,对用户的影响相对较小。