UNPKG

@shopify/shop-minis-react

Version:

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

40 lines (34 loc) 961 B
import {useShopActions} from '../../internal/useShopActions' import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching' import { PaginatedDataHookOptionsBase, PaginatedDataHookReturnsBase, ProductList, } from '../../types' interface UseProductListsParams extends PaginatedDataHookOptionsBase { /** * The number of products to fetch per product list. */ itemsFirst?: number } interface UseProductListsResult extends PaginatedDataHookReturnsBase { productLists: ProductList[] | null } export const useProductLists = ( params?: UseProductListsParams ): UseProductListsResult => { const {getProductLists} = useShopActions() const {skip, ...shopActionParams} = params ?? {} const {data, ...rest} = useShopActionsPaginatedDataFetching( getProductLists, shopActionParams, { skip, hook: 'useProductLists', } ) return { ...rest, productLists: data, } }