Skip to content
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

Add ref callback test for cleanup fn vs null call #28895

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

jackpope
Copy link
Contributor

Used this test scenario to clarify how callback refs work when detached based on the availability of a cleanup function to update documentation in reactjs/react.dev#6770

Checking it in for additional test coverage and test-based documentation

@jackpope jackpope requested a review from noahlemen April 23, 2024 15:29
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 23, 2024
Copy link
Member

@noahlemen noahlemen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be worth calling root.unmount() and making assertions on the behavior around that as well?

// New ref is setup
expect(setup2).toBeCalledWith('test-div2');
expect(setup2).toHaveBeenCalledTimes(1);
expect(cleanUp2).toHaveBeenCalledTimes(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanUp2 doesn't seem to be used anywhere?

@react-sizebot
Copy link

react-sizebot commented Apr 23, 2024

Comparing: 699d03c...2ab758f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 497.71 kB 497.71 kB = 88.93 kB 88.93 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 504.00 kB 504.00 kB = 89.95 kB 89.95 kB
facebook-www/ReactDOM-prod.classic.js = 591.14 kB 591.14 kB = 103.91 kB 103.91 kB
facebook-www/ReactDOM-prod.modern.js = 566.95 kB 566.95 kB = 100.12 kB 100.12 kB
test_utils/ReactAllWarnings.js Deleted 64.80 kB 0.00 kB Deleted 16.14 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 64.80 kB 0.00 kB Deleted 16.14 kB 0.00 kB

Generated by 🚫 dangerJS against 2ab758f

Copy link
Member

@noahlemen noahlemen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... i see there's already another test covering what i suggested.

thanks!

@jackpope jackpope merged commit d4e78c4 into facebook:main Apr 23, 2024
38 checks passed
@jackpope jackpope deleted the ref-cleanup-test branch April 23, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants