UNPKG
@overse/ui-extensions-utils
Version:
latest (1.3.7)
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
Utility functions for Shopify UI Extensions
github.com/by-overse/shopify/tree/main
by-overse/shopify
@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
; };