@shopify/shop-minis-react
Version:
React component library for Shopify Shop Minis with Tailwind CSS v4 support (source-only, requires TypeScript)
44 lines (36 loc) • 994 B
text/typescript
import {useMemo} from 'react'
import {useShopActions} from '../../internal/useShopActions'
import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
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} = useShopActionsPaginatedDataFetching(
getRecentShops,
restParams,
{
skip,
hook: 'useRecentShops',
}
)
const shops = useMemo(() => {
return data ?? null
}, [data])
return {
...rest,
shops,
}
}