【发布时间】:2021-11-22 17:16:57
【问题描述】:
我的 redux todo 应用中有这个选择器:
export const selectTodoSlice = (state) => state.todoReducer;
我必须将其命名为 state.todoReducer,就像我在 store 中定义减速器一样:
import todoReducer from "../features/todo/todoSlice";
const store = configureStore({
reducer: {
todoReducer,
},
});
...否则我会收到有关某些.map() 函数的错误。
所以我想知道这是否是一个约定和规则,即选择器中的这部分返回函数 — state.todoReducer — 必须始终与您命名并传递到您的商店的 reducer 相同?
【问题讨论】:
标签: javascript reactjs redux react-redux redux-toolkit