@shopify/shop-minis-react
Version:
React component library for Shopify Shop Minis with Tailwind CSS v4 support (source-only, requires TypeScript)
36 lines (30 loc) • 846 B
text/typescript
import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
import {useShopActions} from '../../internal/useShopActions'
import {
PaginatedDataHookOptionsBase,
PaginatedDataHookReturnsBase,
Shop,
} from '../../types'
export interface UseRecentShopsParams extends PaginatedDataHookOptionsBase {}
interface UseRecentShopsReturns extends PaginatedDataHookReturnsBase {
/**
* The recent shops returned from the query.
*/
shops: Shop[] | null
}
export const useRecentShops = (
params?: UseRecentShopsParams
): UseRecentShopsReturns => {
const {getRecentShops} = useShopActions()
const {skip = false, ...restParams} = params ?? {}
const {data, ...rest} = useShopActionInfiniteQuery(
['recentShops', restParams],
getRecentShops,
restParams,
{skip}
)
return {
...rest,
shops: data,
}
}