-
-
Notifications
You must be signed in to change notification settings - Fork 202
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: Bubble.List re-render #479
base: main
Are you sure you want to change the base?
Conversation
📝 Walkthrough概述遍历在 变更
可能相关的 PRs
诗歌
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 (
|
Bundle ReportBundle size has no change ✅ |
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)
components/bubble/Bubble.tsx (1)
115-118
: 建议:考虑 messageRender 的性能影响使用 useMemo 缓存 mergedContent 是个好主意,但要注意以下几点:
- 如果 messageRender 是一个内联函数,每次渲染都会创建新的引用,这样会导致缓存失效
- 建议将 messageRender 也使用 useCallback 包装,以确保缓存的有效性
示例代码:
+ const memoizedMessageRender = React.useCallback( + (content: any) => messageRender(content), + [messageRender] + ); const mergedContent = React.useMemo( - () => (messageRender ? messageRender(typedContent as any) : typedContent), + () => (messageRender ? memoizedMessageRender(typedContent as any) : typedContent), [typedContent, messageRender], );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/bubble/Bubble.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test / react component workflow
- GitHub Check: build preview
- GitHub Check: size
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: test / react component workflow
- GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
components/bubble/Bubble.tsx (1)
109-112
: 优化:使用 useMemo 缓存 avatarNode 是个好的改进!通过 useMemo 缓存 avatarNode 可以避免在 avatar prop 没有变化时的不必要重渲染,这是一个很好的性能优化。依赖数组的设置也很准确。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #479 +/- ##
==========================================
+ Coverage 91.45% 91.46% +0.01%
==========================================
Files 67 67
Lines 1462 1464 +2
Branches 385 368 -17
==========================================
+ Hits 1337 1339 +2
Misses 125 125 ☔ View full report in Codecov by Sentry. |
size-limit report 📦
|
Deploying ant-design-x with Cloudflare Pages
|
需要加个测试用例么? |
感觉有必要,我想下怎么加好些。 |
fix: #402
before
now