Make withSize use a wrapper element so that it can stop calling findDOMNode#5988
Open
mstange wants to merge 2 commits into
Open
Make withSize use a wrapper element so that it can stop calling findDOMNode#5988mstange wants to merge 2 commits into
mstange wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5988 +/- ##
==========================================
- Coverage 85.34% 83.76% -1.59%
==========================================
Files 318 329 +11
Lines 31922 34415 +2493
Branches 8834 9522 +688
==========================================
+ Hits 27244 28827 +1583
- Misses 4246 5159 +913
+ Partials 432 429 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
EmptyThreadIndicator and Timeline tests mocked findDOMNode to inject sizes for the WithSize HOC. After WithSize stopped calling findDOMNode, those mocks became no-ops: EmptyThreadIndicator snapshots regressed to zero-width indicators, and Timeline's per-describe override silently fell back to the file-level autoMockElementSize. Switch EmptyThreadIndicator to autoMockElementSize so its snapshots again reflect the 100px container, and drop Timeline's dead override.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
findDOMNodeis deprecated in React 18 and removed in React 19 strict mode. ThewithSizeHOC was the last in-tree caller.This PR makes
withSizerender a<div style="display: contents">wrapper around the wrapped component and observewrapper.firstElementChildvia the existingResizeObserverwrapper, removing the need forfindDOMNode. The HOC is also converted to a function component usinguseState+useRef+useEffect.The docstring previously claimed the size only updates on window resize; that hasn't been true since the HOC moved to
ResizeObserver, so it's been corrected to "whenever the element's size changes".Test fixes
EmptyThreadIndicator.test.tsxandTimeline.test.tsxwere mockingfindDOMNodeto inject sizes into the wrapped component. WithfindDOMNodegone those mocks silently became no-ops —EmptyThreadIndicatorsnapshots showed zero-width indicators andTimeline's per-describe override fell back to the file-levelautoMockElementSize. The second commit replaces the mocks withautoMockElementSize, restoring the previous size assertions.Snapshot deltas
Every snapshot covering a
withSize-wrapped component now includes the new<div style="display: contents">wrapper. The only width/height changes are inEmptyThreadIndicator.test.tsx.snap(still 30/10/20px after the mock fix).Test plan
yarn test(128 suites, 2024 passing)yarn tsdisplay: contentsmakes the wrapper transparent in layout.