@@ -15,9 +15,9 @@ export const useList = (query?: firebase.database.Query | null): ListHook => {
1515 const [ state , dispatch ] = useListReducer ( ) ;
1616
1717 const queryRef = useIsEqualRef ( query , ( ) => dispatch ( { type : 'reset' } ) ) ;
18+ const ref : firebase . database . Query | null | undefined = queryRef . current ;
1819
1920 useEffect ( ( ) => {
20- const ref : firebase . database . Query | null | undefined = queryRef . current ;
2121 if ( ! ref ) {
2222 dispatch ( { type : 'empty' } ) ;
2323 return ;
@@ -30,7 +30,9 @@ export const useList = (query?: firebase.database.Query | null): ListHook => {
3030 dispatch ( { type : 'add' , previousKey, snapshot } ) ;
3131 } ;
3232
33- const onChildChanged = ( snapshot : firebase . database . DataSnapshot | null ) => {
33+ const onChildChanged = (
34+ snapshot : firebase . database . DataSnapshot | null
35+ ) => {
3436 dispatch ( { type : 'change' , snapshot } ) ;
3537 } ;
3638
@@ -41,7 +43,9 @@ export const useList = (query?: firebase.database.Query | null): ListHook => {
4143 dispatch ( { type : 'move' , previousKey, snapshot } ) ;
4244 } ;
4345
44- const onChildRemoved = ( snapshot : firebase . database . DataSnapshot | null ) => {
46+ const onChildRemoved = (
47+ snapshot : firebase . database . DataSnapshot | null
48+ ) => {
4549 dispatch ( { type : 'remove' , snapshot } ) ;
4650 } ;
4751
@@ -60,7 +64,7 @@ export const useList = (query?: firebase.database.Query | null): ListHook => {
6064
6165 const onChildAddedWithoutInitialLoad = (
6266 addedChild : firebase . database . DataSnapshot ,
63- previousKey ?: string
67+ previousKey ?: string | null
6468 ) => {
6569 // process the first batch of children all at once
6670 if ( childrenToProcess > 0 ) {
@@ -103,7 +107,7 @@ export const useList = (query?: firebase.database.Query | null): ListHook => {
103107 ref . off ( 'child_moved' , childMovedHandler ) ;
104108 ref . off ( 'child_removed' , childRemovedHandler ) ;
105109 } ;
106- } , [ dispatch , queryRef ] ) ;
110+ } , [ dispatch , ref ] ) ;
107111
108112 const resArray : ListHook = [ state . value . values , state . loading , state . error ] ;
109113 return useMemo ( ( ) => resArray , resArray ) ;
0 commit comments