UNPKG

@the-overse/ui-extensions-utils

Version:

Utility functions for Shopify UI Extensions

18 lines (14 loc) 317 B
import { useState } from 'react'; export function useFetchState<T>() { const stateArray = useState<FetchState<T>>({ data: null, loading: true, error: null, }); return stateArray; } export type FetchState<T> = { data?: T | null; loading: boolean; error?: unknown | null; };