-
-
Notifications
You must be signed in to change notification settings - Fork 48
Resolve DOM residue issue on activate #70
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
|
Someone is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
Summary of ChangesHello @cactuser-Lu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a DOM residue issue by enhancing the cleanup mechanism within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
概述在 变更
预估代码审查工作量🎯 2 (简单) | ⏱️ ~8 分钟
诗句
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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.
Code Review
This pull request correctly addresses a potential memory leak in the useDomMotionEvents hook. By setting cacheElementRef.current to null within the useEffect cleanup function, it ensures that the reference to the DOM element is properly released upon component unmount. This is an important fix that prevents detached DOM nodes from being retained in memory, improving the application's performance and stability, particularly in scenarios with dynamic component lifecycles. The implementation is clean and effective.
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)
src/hooks/useDomMotionEvents.ts (1)
36-40: 在卸载清理中将cacheElementRef置空是正确的方向这一行在调用
removeMotionEvents(cacheElementRef.current)之后把cacheElementRef.current设为null,可以确保:
- 卸载后不再持有旧的 DOM 引用,避免潜在的泄漏;
- 当 Activity 等场景下重用同一个 DOM 节点重新激活时,
cacheElementRef.current为null,patchMotionEvents不会因为 “element === cacheElementRef.current” 而跳过重新绑定动画/过渡事件,有助于修复 Modal 未正确卸载/动画未结束的残留问题。从类型一致性的角度,可以考虑顺手把 ref 和辅助函数签名调整为显式支持
null,避免 TS 上的细微不一致(运行时行为本身是安全的):const cacheElementRef = useRef<HTMLElement | null>(null); function removeMotionEvents(element: HTMLElement | null) { if (element) { element.removeEventListener(transitionEndName, onInternalMotionEnd); element.removeEventListener(animationEndName, onInternalMotionEnd); } }这样与
cacheElementRef.current = null更匹配,也让调用处不需要依赖宽松的类型检查。
|
这个好写用例吗?看看能不能补一个 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #70 +/- ##
=======================================
Coverage 98.47% 98.48%
=======================================
Files 11 11
Lines 394 395 +1
Branches 108 107 -1
=======================================
+ Hits 388 389 +1
Misses 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fix: ant-design/ant-design#55970
Summary by CodeRabbit
发行说明
✏️ Tip: You can customize this high-level summary in your review settings.