Created
February 4, 2019 07:07
-
-
Save Weiyuan-Lane/7236bb094a1fd72ede4f40a85a55c221 to your computer and use it in GitHub Desktop.
Code splitting illustrating using component splitting library, React Loadable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import Loadable from 'react-loadable' | |
import LoadingComponent from 'scripts/components/LoadingComponent' | |
class ExamplePage extends React.Component { | |
static Component = Loadable({ | |
loader: () => import(/* webpackChunkName: "ExamplePage" */ 'example'), | |
loading: LoadingComponent, // Lightweight LoadingComponent to use whenever this component is first loaded | |
modules: ['ExamplePage'] // Modules to load should be accessible from loader property above | |
}) | |
render() { | |
return <ExamplePage.Component {...this.props} /> | |
} | |
} | |
export default ExamplePage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment