You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a given that using react-hot-loader, you can hot-reload components, but I go one extra step further and hot load route file changes as well with this setup:
/* main entry file */// import dependenciesimportReactfrom'react/addons'importRouterfrom'react-router'importroutesfrom'./routes'importfetchDatafrom'./utils/fetchData'importgetTitlefrom'./utils/getTitle'// create client-side routerconstrouter=Router.create({ routes,location: Router.HistoryLocation})// if this is a hot module update, replace the routes with new stateif(module.hot){module.hot.accept('./routes',()=>router.replaceRoutes(require('./routes')))}// run the approuter.run((Handler,state)=>{fetchData(state.routes,state.params,(err,props)=>{React.render(<Handler{...props}/>,document)document.title=getTitle(state.routes,state.params,props)})})
This is made possible by enabling the manual option on react-hot-loader in the Webpack config like so:
I'm often making changes to the routes.js file and would love to use this project to reduce that fetchData boilerplate code, and not supporting this kind of setup is the only thing keeping me from using this module (really great work, by the way!)
The text was updated successfully, but these errors were encountered:
It's a given that using
react-hot-loader
, you can hot-reload components, but I go one extra step further and hot load route file changes as well with this setup:This is made possible by enabling the
manual
option onreact-hot-loader
in the Webpack config like so:I'm often making changes to the routes.js file and would love to use this project to reduce that
fetchData
boilerplate code, and not supporting this kind of setup is the only thing keeping me from using this module (really great work, by the way!)The text was updated successfully, but these errors were encountered: