The component is loaded the first time it is initialized.
ImportReact, {proptypes} from ' React ';//import Appcomposer from './views/app/appcomposer ';//import Logincomposer from './views/login/logincomposer ';//import Homecomposer from './views/home/homecomposer ';//import Watchlistcomposer from './views/watchlist/watchlistcomposer ';//import Systemlogcomposer from './views/systemlog/systemlogcomposer ';//import Teammanagecomposer from './views/teammanage/teammanagecomposer ';//Import {userquerypage} from './views/userquery/userquerycomposer ';//import Closedcasecomposer from './views/closedcase/closedcasecomposer ';//import Accountinfocomposer from './views/accountinfo/accountinfocomposer ';function Createlazyloadcomponent (doloadcomponent) {return classNewclasscomponentextendsreact.component{Constructor () {Super(..... arguments); This. State ={realcomponent:NULL }; } componentdidmount () {//the component is loaded the first time it is initialized.Doloadcomponent ((pagecomponent) ={ This. SetState ({realcomponent:pagecomponent}); }); } render () {var {realcomponent}= This. State; var props= This. Props; if(realcomponent) {return<realcomponent {... props}/> } return<div>loading...</div>}}}exportConstLogincomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/login/logincomposer '], onloadcallback);}); ExportConstHomecomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/home/homecomposer '], onloadcallback);}); ExportConstWatchlistcomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/watchlist/watchlistcomposer '], onloadcallback);}); ExportConstSystemlogcomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/systemlog/systemlogcomposer '], onloadcallback);}); ExportConstTeammanagecomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/teammanage/teammanagecomposer '], onloadcallback);}); ExportConstClosedcasecomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/closedcase/closedcasecomposer '], onloadcallback);}); ExportConstAccountinfocomposer = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/accountinfo/accountinfocomposer '], onloadcallback);}); ExportConstUserquerypage = Createlazyloadcomponent ((onloadcallback) = ={require (['./views/userquery/userquerycomposer '], ({userquerypage}) ={onloadcallback (userquerypage); });});
React Lazy Loading component