meteor / meteor/react-packages
Double subscriptions when using useTracker in lazy components
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 575
- Forks
- 168
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 1
Description
When using `useTracker` in lazy components I noticed that sometimes data get subscribed, unsubscribed and subscribed again.
This happens because [useMemo][L122] and [useEffect][L127] sometimes gets called synchronously, thus [comp.stop()][L121] gets called too late, resulting in second subscription.
[L122]: https://github.com/meteor/react-packages/blob/501f0ecfbd694d38f35afde4c96b449b69f8b60e/packages/react-meteor-data/useTracker.ts#L112
[L127]: https://github.com/meteor/react-packages/blob/501f0ecfbd694d38f35afde4c96b449b69f8b60e/packages/react-meteor-data/useTracker.ts#L127
[L121]: https://github.com/meteor/react-packages/blob/501f0ecfbd694d38f35afde4c96b449b69f8b60e/packages/react-meteor-data/useTracker.ts#L121
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/react-meteor-data/useTracker.ts, especially the linked useMemo, useEffect, and comp.stop() lines, and reproduce the behavior in a lazy component. Done means preventing the reported duplicate subscribe/unsubscribe/subscribe cycle; the issue names no test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100