-
-
Notifications
You must be signed in to change notification settings - Fork 553
fix(actions): do not dispatch duplicate events from already hooked listeners #995
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
fix(actions): do not dispatch duplicate events from already hooked listeners #995
Conversation
Codecov Report
@@ Coverage Diff @@
## master #995 +/- ##
==========================================
- Coverage 88.33% 88.22% -0.12%
==========================================
Files 29 29
Lines 797 798 +1
==========================================
Hits 704 704
- Misses 93 94 +1 |
|
So something of note: Firebase's SDK should actually internally de-dupe these listeners based on the query - even if you have listeners in multiple places only one actual query is made against the database (this can be proved with the database profiler). This is not clear based on the actions that are being dispatched though (which are not de-deuped) Your PR makes the redux action dispatching more closely match that behavior from the Firebase SDK 👏 At first I was thinking that this should be in a new major version since some apps could function differently with non duplicated action dispatches but then I thought about how dispatching a ton of extra actions isn't really intended functionality 🤔 What are your thoughts? Apologies that this has taken so long to get to |
|
Hi @prescottprue!
I'm aware of that 🙂 However in this case the performance problem is caused by all the React re-renders caused by
I guess it depends how would you treat the actions dispatched by
Thanks for getting back on this and thanks for all the good work on this library! 😎 |
|
Hi @prescottprue! Any progress with this one? 👀 Would love to get this fixed 😄 |
|
Thanks for the reminder |
Awesome! 🤩 Thank you so much! |
Description
src/actions/query.jshooks the listener for each component. If the same data is used in multiple components on the same page each component will trigger a rerender for the other components as well. The amount of renders due to same data updates seem to follow the equation2*n^2wherenis the number of components using the same data. This increases quite quickly and freezes the app.Following example demonstrates the issue. The render method for
Avataris called 840 times. After the patch the render calls go down to 60.Check List
If not relevant to pull request, check off as complete