React 16: Warning: Expected server HTML to contain a matching
in <body>

前端 未结 8 2255
太阳男子
太阳男子 2020-12-17 08:37

Since upgrading to React 16 I get this error message:

warning.js:33 Warning: Expected server HTML to contain a matching

in .

相关标签:
8条回答
  • 2020-12-17 09:23

    I'm assuming you are using ssr. The warning is about attempting to render before there is a window object. You need to hydrate.

    ReactDOM.hydrate(<App />, document.getElementById("home"))
    

    What I don't understand, is that the App component is being served static by express. Why is it trying to render before it is served? Bring on the comments.

    0 讨论(0)
  • If you use ReactDOM.hydrate to start web application, you will see this warning.

    If your application does not use server-side rendering (ssr), please use ReactDOM.render to start.

    0 讨论(0)
提交回复
热议问题