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

Convert findDOMNode-test.js to createRoot #28119

Closed

Conversation

mattcarrollcode
Copy link
Contributor

No description provided.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jan 26, 2024
@@ -11,7 +11,9 @@

const React = require('react');
const ReactDOM = require('react-dom');
const ReactDOMClient = require('react-dom/client');
const ReactTestUtils = require('react-dom/test-utils');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I refactor this test to remove ReactTestUtils?

@react-sizebot
Copy link

Comparing: 7c79daf...e79afde

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.min.js = 176.59 kB 176.59 kB = 55.01 kB 55.01 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.69 kB 178.69 kB = 55.64 kB 55.64 kB
facebook-www/ReactDOM-prod.classic.js = 573.52 kB 573.52 kB = 100.99 kB 100.99 kB
facebook-www/ReactDOM-prod.modern.js = 557.29 kB 557.29 kB = 98.07 kB 98.07 kB
test_utils/ReactAllWarnings.js Deleted 67.55 kB 0.00 kB Deleted 16.54 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 67.55 kB 0.00 kB Deleted 16.54 kB 0.00 kB

Generated by 🚫 dangerJS against e79afde

root.render(<MyNode flag={true} ref={nodeRef} />);
});
const nodeAfterUpdate = nodeRef.current;
expect(nodeAfterInitialRender === nodeAfterUpdate).toBe(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure that this is equivalent to the previous version of the test.

Previous version:

nodeA = ReactDOM.render(<Component>)
nodeB = ReactDOM.render(<UpdatedComponent>)
assert(nodeA === nodeB)

this version:

const ref = React.createRef()
root.render(<Something ref={ref} />)
const componentAfterInitialRender = ref.current
root.render(<UpdatedSomething ref={ref} />)
const componentAfterUpdate= ref.current
assert(componentAfterInitialRender === componentAfterUpdate)

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

3 participants