Redux configureStore添加另一个reducer后出现错误



我当前的商店是这样的:

import { configureStore } from "@reduxjs/toolkit";
import notesReducer from "./notesReducer";
import todoReducer from "./todoReducer";
const store = configureStore({
reducer: todoReducer, // here i wanna add a notesReducer
});
export default store;

如前所述,我想添加一个notesReducer和我在教程中看到的,我可以这样做:

const store = configureStore({
reducer: { todo: todoReducer, note: notesReducer }, 
});

但是,在我的Todos.js文件中部署一个错误:TypeError: props.todos.map is not a function

整个Todos.js文件,所以你可以帮助我找到解决方案或我做错的事情:https://pastebin.com/AWyg8BXW

你的mapStateToProps不应该是

const mapStateToProps = (state) => {
return {
todos: state.todos,
};
};

相关内容

  • 没有找到相关文章

最新更新