File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,14 @@ const isGeneratorFn = (thing) => typeof thing === 'function' &&
10
10
thing . constructor . name === 'GeneratorFunction' ;
11
11
12
12
const useAsyncEffect = ( generator , deps ) => {
13
- let _promise ;
13
+ let promise ;
14
14
15
15
useEffect ( ( ) => {
16
16
if ( ! isGeneratorFn ( generator ) ) {
17
17
throw TypeError ( 'useAsyncEffect requires a generator as the first argument' ) ;
18
18
}
19
19
20
- const promise = CPromise . resolveGenerator ( generator , { resolveSignatures : true } ) ;
21
- _promise = promise ;
20
+ promise = CPromise . resolveGenerator ( generator , { resolveSignatures : true } ) ;
22
21
23
22
let cb ;
24
23
@@ -31,13 +30,13 @@ const useAsyncEffect = (generator, deps) => {
31
30
32
31
return ( ) => {
33
32
promise . cancel ( E_REASON_UNMOUNTED ) ;
34
- _promise = null ;
33
+ promise = null ;
35
34
cb && cb ( ) ;
36
35
}
37
36
} , deps ) ;
38
37
39
38
return [
40
- ( reason ) => ! ! _promise && _promise . cancel ( reason )
39
+ ( reason ) => ! ! promise && promise . cancel ( reason )
41
40
]
42
41
}
43
42
You can’t perform that action at this time.
0 commit comments