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) 914 B
import {useShopActionInfiniteQuery} from '../../internal/reactQuery' import {useShopActions} from '../../internal/useShopActions' 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} = useShopActionInfiniteQuery( ['productLists', shopActionParams], getProductLists, shopActionParams, {skip} ) return { ...rest, productLists: data, } }