Skip to content

Instantly share code, notes, and snippets.

Created Dec 15, 2016
Embed
What would you like to do?
// 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