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

Update ReactDOMServerSuspense-test to not use legacy rendering APIs #28251

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

gnoff
Copy link
Collaborator

@gnoff gnoff commented Feb 5, 2024

Updates ReactDOMServerSuspense-test to not use legacy rendering APIs
Also removes an experimental only gate that is not necessary

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 5, 2024
@react-sizebot
Copy link

react-sizebot commented Feb 5, 2024

Comparing: 952aa74...be76c13

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.37 kB 176.37 kB = 54.96 kB 54.96 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.37 kB 178.37 kB = 55.54 kB 55.54 kB
facebook-www/ReactDOM-prod.classic.js = 590.79 kB 590.79 kB = 104.26 kB 104.26 kB
facebook-www/ReactDOM-prod.modern.js = 574.55 kB 574.55 kB = 101.36 kB 101.36 kB
test_utils/ReactAllWarnings.js Deleted 67.02 kB 0.00 kB Deleted 16.42 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.02 kB 0.00 kB Deleted 16.42 kB 0.00 kB

Generated by 🚫 dangerJS against be76c13

@@ -41,7 +41,7 @@ function initModules() {
};
}

const {itThrowsWhenRendering, resetModules, serverRender} =
const {resetModules, itThrowsWhenRendering} =
Copy link
Member

Choose a reason for hiding this comment

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

@gnoff line 38 is still using ReactDOM instead of ReactDOMClient so the itThrowsWhenRendering tests are still using the legacy renderer.

If you pass ReactDOMClient here:

return {
    ReactDOMClient,
    ReactDOMServer,
    ReactTestUtils,
  };

Then we switch to hyrdateRoot in the helpers:

if (ReactDOMClient) {
ReactDOMClient.hydrateRoot(domElement, reactElement, {
onRecoverableError: () => {
// TODO: assert on recoverable error count.
},
});
} else {
ReactDOM.hydrate(reactElement, domElement);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I didn't realize the I had to return the client version for the utils to use it. I took another look and the thing the itThrowsWhenRendering was asserting actually is wrong now for concurrent roots on the client so really the test only should be asserting on server behavior (also probably what the test was written for originally given the filename). I just ripped out the test utils entirely now and it only uses the underlying modules directly.

Thanks for flagging!

@gnoff gnoff force-pushed the r19-tests-1 branch 2 times, most recently from f9e7047 to f946f51 Compare February 6, 2024 05:05
Updates ReactDOMServerSuspense-test to not use legacy rendering APIs. Previously this test was relying on suspending in the legacy renderer to throw during server rendering as well as during client rendering. With the advent of concurrent roots on the client however this doesn't make sense and it only makes sense on the server when using legacy apis like renderToString.

I have removed the use of ReactDOMServerIntegrationTestUtils in this test suite and limited the tests to server tests using renderToString to keep as much parity with what was being tested before while dropping anything that no longer makes sense to assert on concurrent client roots
Comment on lines -192 to -204
itThrowsWhenRendering(
'a suspending component without a Suspense above',
async render => {
await render(
<div>
<AsyncText text="Children" />
</div>,
1,
);
},
'A component suspended while responding to synchronous input.',
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is essentially a duplicate of the above test

Copy link
Member

Choose a reason for hiding this comment

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

I feel like it's worth keeping in case there's something fucky with having a boundary in the tree

@gnoff gnoff merged commit 0a53c46 into facebook:main Feb 6, 2024
36 checks passed
@gnoff gnoff deleted the r19-tests-1 branch February 6, 2024 05:25
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…acebook#28251)

Updates ReactDOMServerSuspense-test to not use legacy rendering APIs
Also removes an experimental only gate that is not necessary
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
…28251)

Updates ReactDOMServerSuspense-test to not use legacy rendering APIs
Also removes an experimental only gate that is not necessary

DiffTrain build for commit 0a53c46.
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.

4 participants