Skip to content

Commit

Permalink
Allow Suspense Mismatch on the Client to Silently Proceed (facebook#1…
Browse files Browse the repository at this point in the history
…6943)

* 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 and acdlite committed Sep 28, 2019
1 parent 3694a3b commit d346d92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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

0 comments on commit d346d92

Please sign in to comment.