meteorrn / meteor-react-native

Meteor client for React Native matching Meteor Spec
https://guide.meteor.com/react-native.html
Other
59 stars 31 forks source link

useTracker function gets called again at each re-render even while setting deps as [] #96

Closed fidelsam1992 closed 1 year ago

fidelsam1992 commented 2 years ago

Describe the bug

  const myValue = Meteor.useTracker(() => {
    console.log("Called");
    return false
  }, []);

I am getting "Called" multiple times in the console at every re-render

Expected behavior To be called only once

ToyboxZach commented 2 years ago

I believe my branch fixes this issue if you want to give it a try I did a pretty big restructuring of this package: https://github.com/ToyboxZach/meteor-react-native

bratelefant commented 1 year ago

I already commented on the PR #94 There is definitely an issue with useTracker, and @ToyboxZach 's fork solves it.

I subscribe in useTracker to a pub from meteor server, and this gets called ~15 times server side (logged every sub) for one ui view, although dep list is emtpy; this results in heavy server load and really slow response times (up to 6-7 seconds).

TheRealNate commented 1 year ago

@bratelefant We are discussing merging #94. In the meantime, if you can cherry pick the changes from #94 that solve your problem and open a new smaller PR, happy to merge them in

bratelefant commented 1 year ago

I really can't promise that I'm capable to get this done, but I can try to filter out the changes that solve my issue. Will post my results in #94.

github-actions[bot] commented 1 year ago

Closing this issue due to no activity. Feel free to reopen.

jankapunkt commented 1 year ago

This should likely be fixed in #111 please reopen if the issue persists