UNPKG

@shopify/shop-minis-react

Version:

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

42 lines (36 loc) 983 B
import {useShopActionInfiniteQuery} from '../../internal/reactQuery' import {useShopActions} from '../../internal/useShopActions' import { ProductList, PaginatedDataHookOptionsBase, PaginatedDataHookReturnsBase, } from '../../types' interface UseProductListParams extends PaginatedDataHookOptionsBase { /** * The GID of the product list. E.g. `gid://shopapp/ProductList/123`. */ id?: string /** * The public ID of the product list. */ publicId?: string } interface UseProductListResult extends PaginatedDataHookReturnsBase { productList: ProductList | null } export const useProductList = ( params?: UseProductListParams ): UseProductListResult => { const {getProductList} = useShopActions() const {skip, ...shopActionParams} = params ?? {} const {data, ...rest} = useShopActionInfiniteQuery( ['productList', shopActionParams], getProductList, shopActionParams, {skip} ) return { ...rest, productList: data, } }