meteor-react-native icon indicating copy to clipboard operation
meteor-react-native copied to clipboard

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

Open fidelsam1992 opened this issue 2 years ago • 1 comments

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

fidelsam1992 avatar Aug 30 '22 13:08 fidelsam1992

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

ToyboxZach avatar Aug 31 '22 16:08 ToyboxZach

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).

bratelefant avatar Nov 23 '22 14:11 bratelefant

@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

TheRealNate avatar Nov 29 '22 17:11 TheRealNate

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.

bratelefant avatar Nov 29 '22 17:11 bratelefant

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

github-actions[bot] avatar Jan 29 '23 02:01 github-actions[bot]

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

jankapunkt avatar Mar 17 '23 07:03 jankapunkt