React 16 warning “warning.js:36 Warning: Did not expect server HTML to contain a
in
.”

后端 未结 2 708
情书的邮戳
情书的邮戳 2020-12-30 23:25

I\'m using the React 16 beta (react-fiber) with server side rendering

What I am to understand this to mean?

warning.js:36 Warning: Did not expect ser         


        
相关标签:
2条回答
  • 2020-12-30 23:34

    Just change express response from

    <body>
        <div id="root">
            ${markup}
        </div>
    </body>
    

    to

    <body>
        <div id="root">${markup}</div>
    </body>
    

    Remove space between tags

    0 讨论(0)
  • 2020-12-30 23:49

    Looking for that error in the react code it seems that this happens when the SSR html can't be rehydrated.

    https://github.com/facebook/react/blob/7a60a8092144e8ab2c85c6906dd4a7a5815cff1f/src/renderers/dom/fiber/ReactDOMFiberComponent.js#L1022

    So you are somehow initially rendering a different tree on the client vs the server.

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