私が持っているのはroot route定義です:
const rootRoute = {
childRoutes: [{
path: '/',
component: require('./screens/Container'),
appGlobalVars: appGlobalVars,
childRoutes: [
require('./routes/ListApps'),
require('./routes/Settings'),
require('./routes/Profile')
]
}]
};
var runApp = (appGlobalVars) => {
var routes = (
<Provider store={store}>
<Router history={ history } routes={rootRoute} />
</Provider>
);
render(routes, document.getElementById('app'));
};
ネストされた動的ルーティングを使用したいくつかの設定:
./routes/Settings/index.js:
module.exports = {
path: 'settings',
getComponent(nextState, cb) {
require.ensure([], (require) => {
cb(null, require('../../screens/AppSettings'))
})
},
getChildRoutes(partialNextState, cb) {
require.ensure([], (require) => {
cb(null, [
require('./General'),
require('./Users')
])
})
},
};
/settings{this.props.children}反応ルーターパスをレンダリングする親コンポーネントです。たとえば、/settings/general私がレンダリングしたものに移動すると、その子としてsettingsレンダリングされます。general
./routes/Settings/General.js
module.exports = {
path: 'general',
getComponent(nextState, cb) {
require.ensure([], (require) => {
cb(null, require('../../screens/AppSettings/General'))
})
}
};
これは問題ありませんが、私がやりたいのは、にSettings移動した場合にレンダリングするデフォルトの子コンポーネントを定義することです/settings。
要するに、IndexRoute動的ルーティングを使用するときのようなものを定義する方法はありますか?