From 03e6b8ba2fb1c2820d2a5286701ff2b40590b438 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 25 May 2020 18:16:53 -0700 Subject: [PATCH] Make LegacyHidden match semantics of old fork (#18998) Facebook currently relies on being able to hydrate hidden HTML. So skipping those trees is a regression. We don't have a proper solution for this in the new API yet. So I'm reverting it to match the old behavior. Now the server renderer will treat LegacyHidden the same as a fragment, with no other special behavior. We can only get away with this because we assume that every instance of LegacyHidden is accompanied by a host component wrapper. In the hidden mode, the host component is given a `hidden` attribute, which ensures that the initial HTML is not visible. To support the use of LegacyHidden as a true fragment, without an extra DOM node, we will have to hide the initial HTML in some other way. --- ...DOMServerPartialHydration-test.internal.js | 71 +++++++++++++------ .../src/server/ReactPartialRenderer.js | 20 +++--- .../src/ReactFiberBeginWork.new.js | 9 +-- scripts/jest/TestFlags.js | 3 + 4 files changed, 63 insertions(+), 40 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js index 01114efa5c..6080a26964 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js @@ -87,6 +87,38 @@ describe('ReactDOMServerPartialHydration', () => { SuspenseList = React.SuspenseList; }); + // Note: This is based on a similar component we use in www. We can delete + // once the unstable_LegacyHidden API exists in both forks, and once the + // extra div wrapper is no longer neccessary. + function LegacyHiddenDiv({children, mode}) { + let wrappedChildren; + if (gate(flags => flags.new)) { + // The new reconciler does not support `