Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { createSelector } from "reselect";
- const selectCart = state => state.cart;
- export const selectCartItems = createSelector(
- [selectCart],
- cart => cart.cartItems
- );
- export const selectCartItemsCount = createSelector(
- [selectCartItems],
- cartItems =>
- cartItems.reduce(
- (accumulatedQuantity, item) => accumulatedQuantity + item.quantity,
- 0
- )
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement