का उपयोग webpack2.2.0-RC1 और routerv4 प्रतिक्रिया है, और इस gist का उपयोग कर काम करने के लिए कोड spliting, जिसमें कहा गया है बनाने के लिए निम्नलिखितसर्वर साइड प्रतिपादन के साथ 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)
)
यह वास्तव में काम करता है, लेकिन मैं सर्वर साइड प्रतिपादन का उपयोग कर रहा हूँ। तो सर्वर पर मुझे घटक ए की आवश्यकता होती है, फिर क्लाइंट I System.import घटक ए पर जब मैं आलसी लोड किए गए मार्ग तक पहुंचता हूं तो मुझे यह प्रतिक्रिया पुन: उपयोग मार्कअप चेतावनी मिलती है क्योंकि क्लाइंट ने प्रस्तुत किया है प्रारंभ में https://gist.github.com/acdlite/a68433004f9d6b4cbc83b5cc3990c194#file-app-js-L21 से घटक लोड करते समय घटक को लोड किया गया ए 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