File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ interface Params<T> {
19
19
}
20
20
21
21
interface Context < T > {
22
- data : T | undefined ;
23
- error : Error | undefined ;
22
+ data ? : T ;
23
+ error ? : Error ;
24
24
isLoading : boolean ;
25
25
isFetching : boolean ;
26
26
}
@@ -30,8 +30,6 @@ interface SWRStore<T> extends Readable<Context<T>> {
30
30
}
31
31
32
32
const defaultContext = {
33
- data : undefined ,
34
- error : undefined ,
35
33
isLoading : false ,
36
34
isFetching : false ,
37
35
} ;
@@ -45,11 +43,13 @@ const defaultOptions = {
45
43
export function useSWR < T > ( ) : SWRStore < T > {
46
44
const client = getClient ( ) ;
47
45
48
- const store = writable < Context < T > > ( { ...defaultContext } ) ;
46
+ const context = { ...defaultContext } ;
47
+
48
+ const store = writable < Context < T > > ( context ) ;
49
49
50
50
const fsm = newFSM ( {
51
51
config : swrMachine ,
52
- context : { ... defaultContext } ,
52
+ context,
53
53
receiveFn : ( state , ctx ) => {
54
54
store . set ( { state, ...ctx } ) ;
55
55
You can’t perform that action at this time.
0 commit comments