useOrders (useOrders)

BookWorm · crm, react-query, data-fetching, order-listing, paginated-orders, filter-hooks, integration

React query hook for fetching a paginated list of orders with optional filters and overrides, centralizing query key and API call.

export default function useOrders(
  query?: ListOrdersQuery,
  options?: Omit<UseQueryOptions<PagedResult<Order>>, "queryKey" | "queryFn">,
) {
  return useQuery({
    queryKey: orderingKeys.orders.list(query),
    queryFn: () => ordersApiClient.list(query),
    ...options,
  });
}

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key