Skip to content

Commit

Permalink
Allow Suspense Mismatch on the Client to Silently Proceed (#16943)
Browse files Browse the repository at this point in the history
* Regression test: Suspense + hydration + legacy

* Allow Suspense Mismatch on the Client to Silently Proceed

This fixes but isn't actually the semantics that we want this case to have.
  • Loading branch information
sebmarkbage authored Sep 28, 2019
1 parent 9d63784 commit d8a76ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit d8a76ad

Please sign in to comment.