使用服务器端渲染时 React 校验和失败
React checksum fails when using server side rendering
我构建了一个同构的 React 应用程序,有时元标记不会在服务器端自动关闭,并且出现以下无效校验和错误:
You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:
(client) -8" data-reactid="3"/><meta http-equiv="
(server) -8" data-reactid="3"><meta http-equiv="X
有没有办法避免这种情况?有什么想法吗?
假设键是相同的(它们看起来是)这是 0.13.*
版本中的 known issue。确保 react
和 react-dom
包裹都至少 0.14.0
你应该是好的。
我构建了一个同构的 React 应用程序,有时元标记不会在服务器端自动关闭,并且出现以下无效校验和错误:
You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:
(client) -8" data-reactid="3"/><meta http-equiv="
(server) -8" data-reactid="3"><meta http-equiv="X
有没有办法避免这种情况?有什么想法吗?
假设键是相同的(它们看起来是)这是 0.13.*
版本中的 known issue。确保 react
和 react-dom
包裹都至少 0.14.0
你应该是好的。