-
-
Notifications
You must be signed in to change notification settings - Fork 783
fix: tipFormatter should not crash with undefined value #1053
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
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Caution Review failedThe pull request is closed. 概述代码变更解析步骤说明本次变更主要涉及两个文件: 变更
序列图sequenceDiagram
participant Component as Tracks组件
participant Data as trackList数据
Component->>Data: 安全访问trackList长度
alt 数据存在
Data-->>Component: 返回长度
else 数据为空/未定义
Data-->>Component: 返回undefined
end
诗歌
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
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 (
|
| }); | ||
| it('tipFormatter should not crash with undefined value', () => { | ||
| [undefined, null].forEach((value) => { | ||
| render(<Slider value={value} tooltip={{ open: true }} styles={{ tracks: {} }}/>); |
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.
为啥要兼容这样的用法?
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.
兼容的是 styles={{ tracks: {} }} 还是 value={null} ?
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.

当使用 classNames.tracks || styles.tracks 的时候 undefined和null 的单测就会报错。
Summary by CodeRabbit
Bug 修复
Tracks组件中添加了可选链接,提高了代码的健壮性,防止在空列表或未定义的情况下出现错误。测试
Slider组件添加了新的测试用例,确保在处理未定义或空值时不会崩溃。