From f18192966747d3def1e110599747acc076eca8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Sun, 2 Sep 2018 15:36:40 +0200 Subject: [PATCH 1/3] Ignore noscript content on the client (#11423) --- .../ReactServerRenderingHydration.js | 33 +++++++++++++++++++ .../src/client/ReactDOMHostConfig.js | 1 + 2 files changed, 34 insertions(+) diff --git a/packages/react-dom/src/__tests__/ReactServerRenderingHydration.js b/packages/react-dom/src/__tests__/ReactServerRenderingHydration.js index 63a0104f0cc60..06ab2a37f592e 100644 --- a/packages/react-dom/src/__tests__/ReactServerRenderingHydration.js +++ b/packages/react-dom/src/__tests__/ReactServerRenderingHydration.js @@ -341,4 +341,37 @@ describe('ReactDOMServerHydration', () => { expect(callback).toHaveBeenCalledTimes(0); } }); + + // Regression test for https://github.com/facebook/react/issues/11423 + it('should ignore noscript content on the client and not warn about mismatches', () => { + const callback = jest.fn(); + const TestComponent = ({onRender}) => { + onRender(); + return
Enable JavaScript to run this app.
; + }; + const markup = ( + + ); + + const element = document.createElement('div'); + element.innerHTML = ReactDOMServer.renderToString(markup); + expect(callback).toHaveBeenCalledTimes(1); + expect(element.textContent).toBe( + '
Enable JavaScript to run this app.
', + ); + + // On the client we want to keep the existing markup, but not render the + // actual elements for performance reasons and to avoid for example + // downloading images. This should also not warn for hydration mismatches. + expect(() => ReactDOM.hydrate(markup, element)).not.toWarnDev( + 'Expected server HTML to contain a matching
in