Skip to content

Commit 46c243a

Browse files
committed
no need for useCallback
1 parent eecab69 commit 46c243a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/react-meteor-data/useTracker.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect, useCallback } from 'react';
1+
import { useState, useEffect } from 'react';
22
import { Tracker } from 'meteor/tracker';
33
import { Meteor } from 'meteor/meteor';
44

@@ -11,15 +11,13 @@ if (Meteor.isServer) {
1111
}
1212
else {
1313
useTracker = (reactiveFn, dependencies) => {
14-
const callback = useCallback(reactiveFn, dependencies);
15-
1614
// Run the function once with no autorun to get the initial return value.
1715
// @todo Reach out to the React team to see if there's a better way ? Maybe abort the initial render instead ?
1816
const [trackerData, setTrackerData] = useState(() => {
1917
// We need to prevent subscriptions from running in that initial run.
2018
const realSubscribe = Meteor.subscribe;
2119
Meteor.subscribe = () => ({ stop: () => {}, ready: () => false });
22-
const initialData = Tracker.nonreactive(callback);
20+
const initialData = Tracker.nonreactive(reactiveFn);
2321
Meteor.subscribe = realSubscribe;
2422
return initialData;
2523
});
@@ -33,7 +31,7 @@ else {
3331
// it stops the inner one.
3432
Tracker.nonreactive(() => {
3533
computation = Tracker.autorun(() => {
36-
const data = callback();
34+
const data = reactiveFn();
3735
if (Package.mongo && Package.mongo.Mongo && data instanceof Package.mongo.Mongo.Cursor) {
3836
console.warn(
3937
'Warning: you are returning a Mongo cursor from useEffect. '
@@ -45,7 +43,7 @@ else {
4543
});
4644
});
4745
return () => computation.stop();
48-
}, [callback]);
46+
}, dependencies);
4947

5048
return trackerData;
5149
};

0 commit comments

Comments
 (0)