Skip to content

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 15, 2026

Summary by CodeRabbit

改进

  • API 增强
    • resize 观察器钩子现在支持直接传入 HTML 元素或返回元素的函数,提供更灵活的目标元素指定方式,优化了依赖跟踪和资源清理。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
resize-observer Ready Ready Preview, Comment Jan 15, 2026 7:04am

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Caution

Review failed

The pull request is closed.

演进总结

修改了 useResizeObserver 钩子函数的 getTarget 参数,使其接受 HTMLElement 或返回 HTMLElement 的函数两种类型。通过运行时类型判断和条件分支来解析目标元素,并相应调整了依赖数组和清理逻辑。

变更内容

组件 / 文件(s) 变更摘要
useResizeObserver 钩子参数类型扩展
src/useResizeObserver.ts
扩宽 getTarget 参数类型:从仅支持函数改为支持 HTMLElement | (() => HTMLElement)。新增运行时类型检查 (typeof getTarget === 'function'),根据类型分别处理直接元素或函数调用。调整 useEffect 依赖数组逻辑,支持静态目标稳定清理。优化cleanup函数使用已解析的目标。

可能相关的 PRs

  • feat: export useResizeObserver hooks #224: 对同一 useResizeObserver 钩子的 getTarget 参数处理进行了更新,允许接受 HTMLElement 或函数类型,涉及运行时目标解析和依赖数组调整,与本 PR 的核心变更直接对应。

估计代码审查工作量

🎯 3 (中等) | ⏱️ ~20 分钟

诗歌

🐰 参数从函数化身,
静态动态皆接纳,
依赖轻盈舞翩跹,
清理逻辑巧重排,
ResizeObserver 更灵活!✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch support-ele


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d3833c and 82e2ee2.

📒 Files selected for processing (1)
  • src/useResizeObserver.ts

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (2d3833c) to head (82e2ee2).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #225      +/-   ##
==========================================
+ Coverage   94.07%   94.16%   +0.08%     
==========================================
  Files           6        6              
  Lines         135      137       +2     
  Branches       38       40       +2     
==========================================
+ Hits          127      129       +2     
  Misses          7        7              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zombieJ zombieJ merged commit 41982ee into master Jan 15, 2026
9 of 10 checks passed
@zombieJ zombieJ deleted the support-ele branch January 15, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants