UNPKG

@shopify/shop-minis-react

Version:

React component library for Shopify Shop Minis with Tailwind CSS v4 support (source-only, requires TypeScript)

47 lines (39 loc) 1.1 kB
import {useMemo} from 'react' import {useShopActions} from '../../internal/useShopActions' import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching' import { PaginatedDataHookOptionsBase, PaginatedDataHookReturnsBase, Product, } from '../../types' export interface UseSavedProductsParams extends PaginatedDataHookOptionsBase { includeSensitive?: boolean } export interface UseSavedProductsReturns extends PaginatedDataHookReturnsBase { products: Product[] | null } /** * Hook to fetch saved (favorited) products. * @param params - Options for the hook. */ export const useSavedProducts = ( params?: UseSavedProductsParams ): UseSavedProductsReturns => { const {getSavedProducts} = useShopActions() const {skip, ...shopActionParams} = params ?? {} const {data, ...rest} = useShopActionsPaginatedDataFetching( getSavedProducts, shopActionParams, { skip, hook: 'useSavedProducts', } ) const products = useMemo(() => { return data ?? null }, [data]) return { ...rest, products, } }