作为参考,我使用 React-Redux Starter Kit ( https://github.com/davezuko/react-redux-starter-kit ) 作为基础项目布局。
我有一个名为 的路由TSP
,我正在使用getComponent
和 reduxconnect()
在容器组件上注入一个 reducer,我希望它会children
在 props 中传递。
getChildRoutes
TSP 路由定义中的 永远不会被调用。
根路由器配置:
import ApplicationLayout from '../layouts/ApplicationLayout';
import Home from './Home';
export const createRoutes = (store) => {
const routes = {
path: '/',
component: ApplicationLayout,
indexRoute: Home,
getChildRoutes (location, next) {
require.ensure([], (require) => {
next(null, [
require('./TSP').default(store),
require('./Home').default,
]);
});
}
};
return routes;
};
export default createRoutes;
嵌套路由器配置 (TSP):
import { injectReducer } from '../../store/reducers';
import Overview from './routes/Overview';
export default (store) => ({
path: '/tsp/:id',
indexRoute: Overview,
getComponent (nextState, next) {
require.ensure([
'./containers/TSPContainer',
'./modules/tsp'
], (require) => {
const TSP = require('./containers/TSPContainer').default;
const reducer = require('./modules/tsp').default;
injectReducer(store, { key: 'tsp', reducer });
next(null, TSP);
});
},
getChildRoutes (location, next) {
debugger
require.ensure([], (require) => {
next(null, [
// Provide store for async reducers and middleware
require('./routes/Offers').default(store),
require('./routes/Reviews').default(store)
]);
});
}
});
我永远不会进入debugger
内部getChildRoutes
。
任何帮助表示赞赏,如果有更多需要查看的文件,我可以添加它们。