1
- import { useState , useEffect , useCallback } from 'react' ;
1
+ import { useState , useEffect } from 'react' ;
2
2
import { Tracker } from 'meteor/tracker' ;
3
3
import { Meteor } from 'meteor/meteor' ;
4
4
@@ -11,15 +11,13 @@ if (Meteor.isServer) {
11
11
}
12
12
else {
13
13
useTracker = ( reactiveFn , dependencies ) => {
14
- const callback = useCallback ( reactiveFn , dependencies ) ;
15
-
16
14
// Run the function once with no autorun to get the initial return value.
17
15
// @todo Reach out to the React team to see if there's a better way ? Maybe abort the initial render instead ?
18
16
const [ trackerData , setTrackerData ] = useState ( ( ) => {
19
17
// We need to prevent subscriptions from running in that initial run.
20
18
const realSubscribe = Meteor . subscribe ;
21
19
Meteor . subscribe = ( ) => ( { stop : ( ) => { } , ready : ( ) => false } ) ;
22
- const initialData = Tracker . nonreactive ( callback ) ;
20
+ const initialData = Tracker . nonreactive ( reactiveFn ) ;
23
21
Meteor . subscribe = realSubscribe ;
24
22
return initialData ;
25
23
} ) ;
33
31
// it stops the inner one.
34
32
Tracker . nonreactive ( ( ) => {
35
33
computation = Tracker . autorun ( ( ) => {
36
- const data = callback ( ) ;
34
+ const data = reactiveFn ( ) ;
37
35
if ( Package . mongo && Package . mongo . Mongo && data instanceof Package . mongo . Mongo . Cursor ) {
38
36
console . warn (
39
37
'Warning: you are returning a Mongo cursor from useEffect. '
45
43
} ) ;
46
44
} ) ;
47
45
return ( ) => computation . stop ( ) ;
48
- } , [ callback ] ) ;
46
+ } , dependencies ) ;
49
47
50
48
return trackerData ;
51
49
} ;
0 commit comments