Skip to content

Instantly share code, notes, and snippets.

Created December 15, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/51f5e16cbcbcdfe8b18141733a08f0d6 to your computer and use it in GitHub Desktop.
Save anonymous/51f5e16cbcbcdfe8b18141733a08f0d6 to your computer and use it in GitHub Desktop.
// routes/Products/routes/ProductEdit/index.js
import { injectReducer } from 'store/reducers'
export default (store) => ({
path : ':id',
getComponent(nextState, cb) {
require.ensure([], (require) => {
const component = require('./container').default
const reducer = require('./reducers').default
injectReducer(store, { key: 'product-edit', reducer })
cb(null, component)
/* Webpack named bundle */
}, 'product-edit')
}
})
// routes/Products/index.js
import { injectReducer } from 'store/reducers'
import ProductEdit from './routes/ProductEdit'
export default (store) => {
return {
path : 'products',
childRoutes: [
ProductEdit(store)
],
getIndexRoute(nextState, cb) {
require.ensure([], (require) => {
const component = require('./container').default
const reducer = require('./reducers').default
injectReducer(store, { key: 'products', reducer })
cb(null, { component })
/* Webpack named bundle */
}, 'products')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment