Using webpack2.2.0-rc1 and react routerv4, and using this gist to make code spliting to work, which states the following
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
AsyncComponent.Component = Component
this.setState({ Component })
})
}
}
render() {
const { Component } = this.state
if (Component) {
return <Component {...this.props} />
}
return null
}
}
}
const Foo = asyncComponent(() =>
System.import('./Foo').then(module => module.default)
)
It actually works, but I am using server side rendering. So on the server I require component A, then on the client I System.import component A.
FInally when I access the lazy loaded route I get this react reuse markup warning because the client rendered
initially loaded null from https://gist.github.com/acdlite/a68433004f9d6b4cbc83b5cc3990c194#file-app-js-L21
while loading Component A.
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) CO 0.0.0 </h1></div><!-- react-empty: 6 -
(server) CO 0.0.0 </h1> </div><div data-radium="tru
How can I make this work without errors?