Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fidelsam1992 opened this issue Aug 30, 2022 · 6 comments
Labels
bug Something isn't working no-issue-activity

Comments

@fidelsam1992
Copy link

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 fidelsam1992 added the bug Something isn't working label Aug 30, 2022
@ToyboxZach
Copy link
Contributor

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
Copy link
Collaborator

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
Copy link
Collaborator

@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
Copy link
Collaborator

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
Copy link

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

@jankapunkt
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity
Projects
None yet
Development

No branches or pull requests

5 participants