哪个减速器应该在react-boilerplate的reducers.js中?

时间:2017-05-23 04:31:27

标签: reactjs reducers react-boilerplate

它在reducers.jscreateReducer函数中说它创建了带有异步加载的主减速器:

/**
 * Creates the main reducer with the asynchronously loaded ones
 */
export default function createReducer(asyncReducers) {
  return combineReducers({
    route: routeReducer,
    global: globalReducer,
    language: languageProviderReducer,
    ...asyncReducers,
  });
}

生成路线时,会在那里注入减速器。那么哪些减速器应该在reducers.js?究竟是什么async reducers

1 个答案:

答案 0 :(得分:1)

/**
 * Creates the main reducer with the dynamically injected ones
 */
export default function createReducer(injectedReducers) {
  return combineReducers({
    route: routeReducer,
    global: `globalReducer`,
    language: languageProviderReducer,
    ...injectedReducers,
  });

我想。它是一个injectReducer而不是asyncReducer。您可以使用它在运行时在组件索引文件中动态注入Reducer,如boileplate示例所示。