UNPKG

@shopify/shop-minis-react

Version:

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

38 lines (32 loc) 935 B
import {useShopActions} from '../../internal/useShopActions' import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching' import { Product, PaginatedDataHookOptionsBase, PaginatedDataHookReturnsBase, } from '../../types' interface UsePopularProductsParams extends PaginatedDataHookOptionsBase {} interface UsePopularProductsReturns extends PaginatedDataHookReturnsBase { products: Product[] | null } /** * @param options - The options for the query */ export const usePopularProducts = ( params?: UsePopularProductsParams ): UsePopularProductsReturns => { const {getPopularProducts} = useShopActions() const {skip, ...shopActionParams} = params ?? {} const {data, ...rest} = useShopActionsPaginatedDataFetching( getPopularProducts, shopActionParams, { skip, hook: 'usePopularProducts', } ) return { ...rest, products: data, } }