Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

What is wrong with my reselect function ? I dont get an output

$
0
0

I want to use reselect. I want to get my shopping cart by the ids.

reselect.ts

import { createSelector } from "reselect";import { RootState } from "../store";export const shoppingCarts = (state: RootState) => state.ShoppingCart;export const getCartById = (state: any, id: string) => createSelector(  shoppingCarts,  state => state.find(cart => cart.product?.id === id));

Index.tsx

  const { product_id } = props;  const shoppingCart = useSelector(state => getCartById(state, product_id));  console.log(shoppingCart);

console log output

[Function memoized]

how can I get the output of my function (or the json value) ?

if I make this

shoppingCart()

then I get this

undefined is not an object (evaluating 'state.ShoppingCart')

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>