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

Allow Suspense Mismatch on the Client to Silently Proceed #16943

Merged
merged 2 commits into from Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -659,4 +659,15 @@ describe('ReactDOMServerHydration', () => {

document.body.removeChild(parentContainer);
});

it('regression test: Suspense + hydration in legacy mode ', () => {
const element = document.createElement('div');
element.innerHTML = '<div>Hello World</div>';
ReactDOM.hydrate(
<React.Suspense>
<div>Hello World</div>
</React.Suspense>,
element,
);
});
});
9 changes: 4 additions & 5 deletions packages/react-reconciler/src/ReactFiberHydrationContext.js
Expand Up @@ -404,11 +404,10 @@ function skipPastDehydratedSuspenseInstance(
let suspenseState: null | SuspenseState = fiber.memoizedState;
let suspenseInstance: null | SuspenseInstance =
suspenseState !== null ? suspenseState.dehydrated : null;
invariant(
suspenseInstance,
'Expected to have a hydrated suspense instance. ' +
'This error is likely caused by a bug in React. Please file an issue.',
);
if (suspenseInstance === null) {
// This Suspense boundary was hydrated without a match.
return nextHydratableInstance;
}
return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
}

Expand Down