use selector example

Example 1: selector for redux

import { createSelector } from 'reselect';

const getProducts = state => state.products.itemsById;
const getCartItemIds = state => state.currentUser.shoppingCart.itemIds;

export const selectShoppingCartItems = createSelector(
  getProducts,
  getCartItemIds,
  (products, itemIds) => itemIds.map(id => products[id])
);

Example 2: useSelector

const result: any = useSelector(selector: Function, equalityFn?: Function)
Copy

Example 3: useSelector

const result: any = useSelector(selector: Function, equalityFn?: Function)
Copied