-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Performance: createListenerCollection #1454
Comments
Can you provide more details on what the specific perf issue is with the existing implementation? A reproduceable CodeSandbox example would help. |
@leshkovichpvl, try this implementation and see if it helps:
|
@ckedar, Unfortunately, this didn't help improve performance. |
Without a real world example of this issue, we can't really do anything here. It looks like you're connecting a lot of components, so I might recommend refactoring to reduce your connected component count. That's going to be bad for performance in other ways that can't be fundamentally fixed by the library. |
Except that our general recommendation for best perf is to connect as many components as possible. |
No, it's to only connect whenever you have a slice of state that you need for a component. But not so much that you're selecting out the individual properties of an object out of an array of objects. That will hurt your performance, because it's running subscriptions and state updates when you should just be passing props. React will optimize those props changes much better than we can. |
That's... not what all the benchmarks have shown. In most scenarios, the cost of running a large number of memoized selectors and If you've got fewer connected components selecting larger chunks of data, they're going to re-render more often. If a given component really only needs one field out of a larger slice, then that's all it should subscribe to. More commonly, the typical pattern is to have a connected parent just read a list of item IDs from the store and render But seriously, that's why v7 is so much faster than v6 - keeping all the computations outside of React until we know that a component has to render. |
On a large application, there are problems with the performance of createListenerCollection.
#1450 I tried to solve this problem using a map, but this led to the wrong order of selector calls.
Any ideas on how to improve performance?
The text was updated successfully, but these errors were encountered: