Checksum Invalid - SSR props to Client

97 views Asked by At

I'm using the react engine react-engine on GitHub to create a node, express app with react for the views.

For the most part, my app is rendered on the server. However, on one page/express route I require the view to be rendered server-side and then for the React to be fully interactive on the client.

So far I've got the view rendering server-side and then being re-loaded/re-mounted by React on the client.

My problem is that I'm now getting the following error:

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

Here's what my code looks like:

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;

The above is initially rendered on the server and then the following re-mounts it on the client:

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')
  );
});

Can anyone see a problem here?

0

There are 0 answers