草庐IT

combineReducers

全部标签

javascript - React/Redux reducer 在初始化期间返回 undefined

我正在开发我的第一个React/Redux项目。一切顺利,然后我尝试创建一个新的reducer。我认为这是一个非常简单的方法,但是当我加载页面时出现错误“ReducerX在初始化期间返回未定义”。跟踪表明这是在combineReducers()中发生的。我发现了几个类似的问题,但没有解决问题。关于这个问题:WhydoIget“Reducer[...]returnedundefinedduringinitialization”despiteprovidinginitialStatetocreateStore()?问题是他们在createStore()中使用了initialState,而我

javascript - 我如何使用 immutable.js 之类的东西在 Redux 中组合多个 combineReducers 函数

我正在使用immutable.JS通过redux-immutablejs管理我的商店。我现在想使用redux-form库,但我在结合reducers时遇到了问题。Redux-immutable提供了一个combineReducers函数,该函数将检查传递给它的所有reducer是否返回不可变对象(immutable对象)。Redux本身提供了一个combineReducers函数,该函数不执行此类检查。Redux-form要求您包含它们的reducer,但我不能使用Reduximmutable的combineReducers这样做,因为它会失败。所以我要做的基本上是像这样组合这两个函数

javascript - Redux - combineReducers 如何知道将应用状态的哪个子集传递给 reducer

在Reduxbasicstutorial关于Reducers的部分我不太明白以下语法如何推断出应用程序状态的哪个子集要传递给调用combineReducers时引用的每个reducer。是不是单纯的匹配reducer名字上的状态成员名字?import{combineReducers}from'redux'import{ADD_TODO,COMPLETE_TODO,SET_VISIBILITY_FILTER,VisibilityFilters}from'./actions'const{SHOW_ALL}=VisibilityFiltersfunctionvisibilityFilter(

javascript - 测试 Redux 组合 reducer

假设我有几个reducer函数,我使用combineReducers(...)将它们全部组合到一个reducer中,有没有一种方法可以测试组合的reducer实际包含哪些reducer?例如,如果我有这个:import{combineReducers}from'redux'constreducer1=(state,action)=>{...}...(morereducers,etc)constrootReducer=combineReducers({reducer1,reducer2,reducer3})exportdefaultrootReducer我可以使用Mocha和Expect

javascript - 传递 React Redux 意外键以创建商店

我收到错误Unexpectedkey"characters"foundininitialStateargumentpassedtocreateStore。预计会找到一个已知的reducer键:“marvelReducer”、“routing”。意外键将被忽略。根reducer:import{combineReducers}from'redux';import{routerReducer}from'react-router-redux';importmarvelReducerfrom'./marvelReducer';constrootReducer=combineReducers({m

javascript - 终极版;通过 combineReducers 使用组合化简器时访问状态的其他部分

更新感谢@DominicTobias和@gabdallah发现了我令人尴尬的错误。当然是正确答案;sotrycheckingaction.payload.关于switch语句和操作对象的其他评论我们指的是我在我的示例中犯的错误,我已经更正了这些错误。假设我组合了以下两个reducer;import{combineReducers}from'redux'import{routerStateReducer}from'redux-router'importentriesfrom'./entries'exportdefaultcombineReducers({router:routerStat

dart - 如何在 Dart 中使用 `combineReducers` 指定类型注释?

我在List收到一条消息来自linter说:Specifytypeannotations但是我不明白它想要什么类型。对于Map我可以这样:{}我的Map在哪里在最后,我在开头指定了类型,但是我找不到适合我的reducer和我的epics的正确类型。我当前的代码:finalprofileReducer=combineReducers([TypedReducer(_updateProfileBalance),TypedReducer(_setProfile),]);和:finalepics=combineEpics([TypedEpic(profileEpic),]);

dart - 如何在 Dart 中使用 `combineReducers` 指定类型注释?

我在List收到一条消息来自linter说:Specifytypeannotations但是我不明白它想要什么类型。对于Map我可以这样:{}我的Map在哪里在最后,我在开头指定了类型,但是我找不到适合我的reducer和我的epics的正确类型。我当前的代码:finalprofileReducer=combineReducers([TypedReducer(_updateProfileBalance),TypedReducer(_setProfile),]);和:finalepics=combineEpics([TypedEpic(profileEpic),]);