Repository navigation
fix(common): Support both resize observer export shapes - #4193
minwookshin wants to merge 2 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe ChangesuseResizeObserver Export Compatibility
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The supported dependency and build paths have no identified compatibility failure. This change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The compatibility adapter preserves the existing package boundary and does not give callers new authority or control over dependency selection. No material security risk was identified in the changed behavior. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
modules/react/common/lib/utils/useResizeObserver.ts(node:2) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///eslint.config.js?mtime=1791216040873 is not specified and it doesn't parse as CommonJS. Oops! Something went wrong! :( ESLint: 10.12.0 TypeError: scopeManager.addGlobals is not a function modules/react/common/spec/useResizeObserver.spec.tsESLint skipped: the matched ESLint configuration already failed (plugin-compatibility). 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 |
Summary
Fixes #4190 using the compatibility approach proposed in the issue. Resolve either the v9 default export or the v10 named export through a namespace helper, and keep the public hook declaration independent of the installed dependency.
The dependency stays at
^9.1.0, preserving React 17 support. Consumers on React 19 still need to override/resolution-pinuse-resize-observerto v10; this removes the additional source patch.Release Category
Components
Release Note
The
useResizeObserverexport now accepts either v9 or v10 of the underlying package. Overriding to v10 retains that version's behavior, including reporting a measured zero as0.Checklist
ready for reviewhas been added to PRFor the Reviewer
Where Should the Reviewer Start?
modules/react/common/lib/utils/useResizeObserver.ts. The structural ref type accepts the nullable refs used by React 17, 18 and 19 without tying declarations to either dependency version.Testing Manually
Tested isolated installations of React 17.0.2/v9.1.0, React 18.3.1/v9.1.0, React 18.3.1/v10.0.0 and React 19.2.0/v10.0.0. Both webpack and esbuild build without missing-export warnings; the original wrapper produces that warning with v10.
Browser checks cover initial size, resizing, rounding, callback refs/object refs, zero size and unmount. All four combinations pass in Chromium; React 19/v10 also passes in Firefox and WebKit. Strict declaration checks, three export-shape unit tests, repository source/spec/type checks and scoped ESLint pass.
Summary by CodeRabbit
Bug Fixes
Tests