Nested Fractal routing doesn't display the nested component
My problem is that I have a route called "events" then I want to assign a nested route to that called "newRoute" and follows the "Fractal structure writeup" and add "childRoutes: [ NewRoute(state) ]" on the "events" index.js. when I visit the path "events/newRoutes" it works fine but the component connected to "newRoutes" is not load nor displayed when I visit the route. included the two files bellow.
Events/index.js:
import { injectReducer } from '../../store/reducers'
import NewRoute from "./routes/newRoute"
export default (store) => ({
path: 'events',
childRoutes: [
NewRoute(store)
],
/* Async getComponent is only invoked when route matches */
getComponent (nextState, cb) {
/* Webpack - use 'require.ensure' to create a split point
and embed an async module loader (jsonp) when bundling */
require.ensure([], (require) => {
/* Webpack - use require callback to define
dependencies for bundling */
const Events = require('./containers/EventsContainer').default
const reducer = require('./modules/events').default
/* Add the reducer to the store on key 'programme' */
injectReducer(store, { key: 'events', reducer })
/* Return getComponent */
cb(null, Events)
console.log(Events)
/* Webpack named bundle */
}, 'events')
}
})
Events/routes/newRoute/index.js:
/**
* Created by nielshansen on 09/05/16.
*/
import { injectReducer } from '../../../../store/reducers'
export default (store) => ({
path: 'newRoute',
/* Async getComponent is only invoked when route matches */
getComponent (nextState, cb) {
/* Webpack - use 'require.ensure' to create a split point
and embed an async module loader (jsonp) when bundling */
require.ensure([], (require) => {
/* Webpack - use require callback to define
dependencies for bundling */
const NewRoute = require('./containers/NewRouteContainer').default
const reducer = require('./modules/newRoute').default
/* Add the reducer to the store on key 'programme' */
injectReducer(store, { key: 'newRoute', reducer })
/* Return getComponent */
cb(null, NewRoute)
console.log(NewRoute)
/* Webpack named bundle */
}, 'newRoute')
}
})
The parent route component - the one that EventsContainer connects to (Events?) - needs to include {props.children} to include the sub route component(s).
e.g. if the Events component was as follows then the newRoute component would be inserted between the divs:
<div>{props.children}</div>
@SteveHoggNZ of course that is what is missing! starred me completely blind on this.
Thanks! can be closed :-)