-
Notifications
You must be signed in to change notification settings - Fork 74
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
mergeCollection
: individual collection item subscriber is called even if the value did not change
#535
Comments
@tgolen @chrispader WDYT about this issue? |
I agree with the improvement you've suggested! It would make it work more consistently with the rest of the functions. |
i can look into this over the next days, or if you want to work on this @paultsimura go ahead :) |
Thanks @chrispader, I tagged you here on purpose in case you'd like to work on it 🙂 |
Got it! I'll look into it |
Hey @chrispader, did you have any luck looking into this so far? |
i can look into it today! |
Fixed in #541 :) |
Thanks @chrispader 💪🏽 |
I think we can close this :) @tgolen |
When executing
mergeCollection
, Onyx calls the collection subscriber callback and all the collection items subscribers callbacks, even if those items did not change.As a result, if there is a React component subscribed to a single collection item (e.g. a specific Report) and uses this item as a hook dependency (e.g.
useEffect(..., [report])
), the hook is executed every time the collection is merged, even if this specific item did not change.Suggested solution: call individual collection item subscribers only if the item changes.
Example unit test that should succeed:
The text was updated successfully, but these errors were encountered: