次WebPACKの2コードSplitingして反応-ルータ-V4を
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)
)
それを述べている、webpack2.2.0-rc1の使い方とrouterv4反応、およびコードsplitingが動作するようにするために、このgistを使用して実際には動作しますが、私はサーバーサイドレンダリングを使用しています。サーバ上でコンポーネントAが必要な場合は、クライアントIのSystem.importコンポーネントAを要求します。 Filledことがあります。遅延ロードされたルートにアクセスすると、このクライアントはhttps://gist.github.com/acdlite/a68433004f9d6b4cbc83b5cc3990c194#file-app-js-L21 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
どうすればこの作業を間違いなく行うことができますか?
あなたは、このためのソリューションを越えてきたから遠く離れているのですか? –
多くのソリューション。リアクション非同期コンポーネント、古いハックただしないでください。反復読み込み可能、新しいハックリアクションユニバーサルコンポーネントは、新しいハックをさらに改善します。 – CESCO