File tree Expand file tree Collapse file tree 4 files changed +66
-54
lines changed Expand file tree Collapse file tree 4 files changed +66
-54
lines changed Original file line number Diff line number Diff line change @@ -18,24 +18,27 @@ export const useCollection = (
18
18
> ( ) ;
19
19
const ref = useIsEqualRef ( query , reset ) ;
20
20
21
- useEffect ( ( ) => {
22
- if ( ! ref . current ) {
23
- reset ( ) ;
24
- return ;
25
- }
26
- const listener =
27
- options && options . snapshotListenOptions
28
- ? ref . current . onSnapshot (
29
- options . snapshotListenOptions ,
30
- setValue ,
31
- setError
32
- )
33
- : ref . current . onSnapshot ( setValue , setError ) ;
21
+ useEffect (
22
+ ( ) => {
23
+ if ( ! ref . current ) {
24
+ setValue ( undefined ) ;
25
+ return ;
26
+ }
27
+ const listener =
28
+ options && options . snapshotListenOptions
29
+ ? ref . current . onSnapshot (
30
+ options . snapshotListenOptions ,
31
+ setValue ,
32
+ setError
33
+ )
34
+ : ref . current . onSnapshot ( setValue , setError ) ;
34
35
35
- return ( ) => {
36
- listener ( ) ;
37
- } ;
38
- } , [ ref . current ] ) ;
36
+ return ( ) => {
37
+ listener ( ) ;
38
+ } ;
39
+ } ,
40
+ [ ref . current ]
41
+ ) ;
39
42
40
43
return [ value , loading , error ] ;
41
44
} ;
Original file line number Diff line number Diff line change @@ -18,16 +18,19 @@ export const useCollectionOnce = (
18
18
> ( ) ;
19
19
const ref = useIsEqualRef ( query , reset ) ;
20
20
21
- useEffect ( ( ) => {
22
- if ( ! ref . current ) {
23
- reset ( ) ;
24
- return ;
25
- }
26
- ref . current
27
- . get ( options ? options . getOptions : undefined )
28
- . then ( setValue )
29
- . catch ( setError ) ;
30
- } , [ ref . current ] ) ;
21
+ useEffect (
22
+ ( ) => {
23
+ if ( ! ref . current ) {
24
+ setValue ( undefined ) ;
25
+ return ;
26
+ }
27
+ ref . current
28
+ . get ( options ? options . getOptions : undefined )
29
+ . then ( setValue )
30
+ . catch ( setError ) ;
31
+ } ,
32
+ [ ref . current ]
33
+ ) ;
31
34
32
35
return [ value , loading , error ] ;
33
36
} ;
Original file line number Diff line number Diff line change @@ -18,24 +18,27 @@ export const useDocument = (
18
18
> ( ) ;
19
19
const ref = useIsEqualRef ( docRef , reset ) ;
20
20
21
- useEffect ( ( ) => {
22
- if ( ! ref . current ) {
23
- reset ( ) ;
24
- return ;
25
- }
26
- const listener =
27
- options && options . snapshotListenOptions
28
- ? ref . current . onSnapshot (
29
- options . snapshotListenOptions ,
30
- setValue ,
31
- setError
32
- )
33
- : ref . current . onSnapshot ( setValue , setError ) ;
21
+ useEffect (
22
+ ( ) => {
23
+ if ( ! ref . current ) {
24
+ setValue ( undefined ) ;
25
+ return ;
26
+ }
27
+ const listener =
28
+ options && options . snapshotListenOptions
29
+ ? ref . current . onSnapshot (
30
+ options . snapshotListenOptions ,
31
+ setValue ,
32
+ setError
33
+ )
34
+ : ref . current . onSnapshot ( setValue , setError ) ;
34
35
35
- return ( ) => {
36
- listener ( ) ;
37
- } ;
38
- } , [ ref . current ] ) ;
36
+ return ( ) => {
37
+ listener ( ) ;
38
+ } ;
39
+ } ,
40
+ [ ref . current ]
41
+ ) ;
39
42
40
43
return [ value , loading , error ] ;
41
44
} ;
Original file line number Diff line number Diff line change @@ -18,16 +18,19 @@ export const useDocumentOnce = (
18
18
> ( ) ;
19
19
const ref = useIsEqualRef ( docRef , reset ) ;
20
20
21
- useEffect ( ( ) => {
22
- if ( ! ref . current ) {
23
- reset ( ) ;
24
- return ;
25
- }
26
- ref . current
27
- . get ( options ? options . getOptions : undefined )
28
- . then ( setValue )
29
- . catch ( setError ) ;
30
- } , [ ref . current ] ) ;
21
+ useEffect (
22
+ ( ) => {
23
+ if ( ! ref . current ) {
24
+ setValue ( undefined ) ;
25
+ return ;
26
+ }
27
+ ref . current
28
+ . get ( options ? options . getOptions : undefined )
29
+ . then ( setValue )
30
+ . catch ( setError ) ;
31
+ } ,
32
+ [ ref . current ]
33
+ ) ;
31
34
32
35
return [ value , loading , error ] ;
33
36
} ;
You can’t perform that action at this time.
0 commit comments