1

我正在使用GitHub 上的反应引擎 react-engine来创建一个节点,表达应用程序并为视图做出反应。

在大多数情况下,我的应用程序是在服务器上呈现的。但是,在一页/快速路由上,我需要在服务器端呈现视图,然后让 React 在客户端完全交互。

到目前为止,我已经在服务器端进行了视图渲染,然后由 React 在客户端重新加载/重新安装。

我的问题是我现在收到以下错误:

bundle.js:357 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:

(client) <section data-reactroot="" data-reactid (server) <section cl

这是我的代码的样子:

class FormCreate extends React.Component {

  render() {
    return (
      <ReactBlank title="Create new application form" messages={this.props.messages} authUser={this.props.authUser}>
        <script dangerouslySetInnerHTML={{
          __html: 'window.PROPS=' + JSON.stringify(this.props)
        }} />
        <div id="app-content">
          <Main {...this.props}/>
        </div>
      </ReactBlank>
    );
  }
}

FormCreate.propTypes = {
  messages: React.PropTypes.array,
  authUser: React.PropTypes.object,
  form: React.PropTypes.object
};

module.exports = FormCreate;

上面的内容最初在服务器上呈现,然后在客户端上重新挂载:

var React = require('react');
var ReactDOM = require('react-dom');
var Main = require('./app/views/shared/builder/Main.jsx');

document.addEventListener('DOMContentLoaded', function onLoad() {
const propScript = document.getElementById('react-engine-props');

const props = window.PROPS;

  ReactDOM.render(
    <Main {...props} />,
    document.getElementById('app-content')
  );
});

任何人都可以在这里看到问题吗?

4

0 回答 0