UNPKG
@the-overse/ui-extensions-utils
Version:
latest (1.2.2)
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
Utility functions for Shopify UI Extensions
github.com/by-overse/shopify/tree/main
by-overse/shopify
@the-overse/ui-extensions-utils
/
src
/
hooks
/
useFetchState
/
index.ts
18 lines
(14 loc)
•
317 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
; };