Skip to content

[Fizz] Add failing test for failed hydration when using uSES in StrictMode #26113

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

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,50 @@ describe('ReactDOMFizzServer', () => {
},
);

it('can hydrate uSES in StrictMode with different client and server snapshot', async () => {
function subscribe() {
return () => {};
}
function getClientSnapshot() {
return 'Yay!';
}
function getServerSnapshot() {
return 'Nay!';
}

function App() {
const value = useSyncExternalStore(
subscribe,
getClientSnapshot,
getServerSnapshot,
);
Scheduler.log(value);

return value;
}

const element = (
<React.StrictMode>
<App />
</React.StrictMode>
);

await act(async () => {
const {pipe} = renderToPipeableStream(element);
pipe(writable);
});

assertLog(['Nay!']);
expect(getVisibleChildren(container)).toEqual('Nay!');

await clientAct(() => {
ReactDOMClient.hydrateRoot(container, element);
});

expect(getVisibleChildren(container)).toEqual('Yay!');
assertLog(['Nay!', 'Yay!']);
});

it(
'errors during hydration force a client render at the nearest Suspense ' +
'boundary, and during the client render it recovers',
Expand Down