Webpack Dev-Server 和 React 服务器端渲染
Webpack Dev-Server And React Server Side rendering
我正在试验同构 React 应用程序,在 webpack 开发服务器上进行热加载时遇到问题。我收到此错误:
warning.js:44 Warning: React attempted to reuse markup in a container
but the checksum was invalid. This generally means that you are using
server rendering and the markup generated on the server was not what
the client was expecting. React injected new markup to compensate
which works but you have lost many of the benefits of server
rendering. Instead, figure out why the markup being generated is
different on the client or server
我知道这是什么意思,但我不知道如何解决它。
另外,请注意,这 ONLY 发生在我更改导致开发服务器热重新加载的代码时,在生产或开发服务器的初始加载时,不会显示任何警告。
提前致谢!
经过一些过期后,我意识到只有在编辑 React Stateless Functions, as mentioned here.
时才会出现问题
将组件更改为它的 ES6 class 形式,问题就解决了。请注意,react-hot-loader v3.x
(目前是 alpha)没有这个问题。
我正在试验同构 React 应用程序,在 webpack 开发服务器上进行热加载时遇到问题。我收到此错误:
warning.js:44 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server
我知道这是什么意思,但我不知道如何解决它。
另外,请注意,这 ONLY 发生在我更改导致开发服务器热重新加载的代码时,在生产或开发服务器的初始加载时,不会显示任何警告。
提前致谢!
经过一些过期后,我意识到只有在编辑 React Stateless Functions, as mentioned here.
时才会出现问题
将组件更改为它的 ES6 class 形式,问题就解决了。请注意,react-hot-loader v3.x
(目前是 alpha)没有这个问题。