【发布时间】:2021-08-17 15:40:44
【问题描述】:
为什么会出现此错误:
undefined 不是一个对象。 state.shopping_cart
重新选择
import { createSelector } from 'reselect';
const carts = state => state.shopping_cart.cart;
export const allCarts = createSelector(
carts,
(data) => data
);
购物车:
import { createSlice } from "@reduxjs/toolkit";
import _ from 'lodash';
const shopping_cart = createSlice({
name: 'shopping_cart',
initialState: {
cart: []
},
....
});
export const { addCart, removeCart, removeCartByProductID, addAmountOnCartItem } = shopping_cart.actions;
export default shopping_cart.reducer;
我是这样打电话的:
allCarts();
【问题讨论】:
标签: react-native redux expo reselect