-
Notifications
You must be signed in to change notification settings - Fork 45
feat: Remove findDOMNode #216
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 ↗︎
|
总览变更概述这个拉取请求主要涉及从 变更
序列图sequenceDiagram
participant Component as ResizeObserver
participant Util as @rc-component/util
participant DOM as DOM Element
Component->>Util: 获取 DOM 元素
Util-->>Component: 返回 DOM 元素
Component->>DOM: 观察大小变化
DOM-->>Component: 触发 resize 事件
诗歌
✨ Finishing Touches
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 (
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
findDOMNode<HTMLElement>(wrapperRef.current); | ||
const getDomElement = () => { | ||
return getDOM( elementRef.current ) as HTMLElement | ||
} |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
the enclosing function
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #216 +/- ##
==========================================
- Coverage 94.24% 93.93% -0.31%
==========================================
Files 6 5 -1
Lines 139 132 -7
Branches 42 37 -5
==========================================
- Hits 131 124 -7
Misses 7 7
Partials 1 1 ☔ View full report in Codecov by Sentry. |
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)
tests/index.spec.js (1)
237-237
: 验证行为变更的断言正确这个断言正确反映了移除 findDOMNode 后的预期行为,即对于非 ref-able 的组件不应触发 resize 事件。
不过建议添加一个相关的测试用例来验证错误处理:
+ it('should warn when child is not ref-able', () => { + const Wrapper = props => <>{props.children}</>; + mount( + <ResizeObserver> + <Wrapper> + <div /> + </Wrapper> + </ResizeObserver>, + ); + expect(errorSpy).toHaveBeenCalledWith( + expect.stringContaining('can not get DOM element'), + ); + });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/index.spec.js
(2 hunks)tests/ref.spec.tsx
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/ref.spec.tsx
🔇 Additional comments (1)
tests/index.spec.js (1)
Line range hint
222-236
: 测试用例实现完整且清晰测试用例通过简单的 Wrapper 组件很好地验证了 ResizeObserver 对非 ref-able 组件的处理行为。实现方式简洁明了。
Summary by CodeRabbit
发行说明
依赖变更
rc-util
替换为@rc-component/util
功能调整
DomWrapper
组件SingleObserver
组件的 DOM 处理方法测试更新
ResizeObserver
组件的测试用例这些变更旨在优化组件的性能和可靠性,同时保持核心功能不变。