philipp-spiess / use-substate

🍙 Lightweight (<600B minified + gzipped) React Hook to subscribe to a subset of your single app state.
https://github.com/philipp-spiess/use-substate
MIT License
99 stars 1 forks source link

Performance #3

Closed Jaikant closed 5 years ago

Jaikant commented 5 years ago

This is a great library and I intend to talk about this in my local meet-up with probably a demo/code review of how it is implemented.

A question I had and which could also be expected from the audience is how does it compare in performance to react-redux?

Here is a good issue, I have been reading which talks of some of react-redux's performance challenges

philipp-spiess commented 5 years ago

Hi!

This solution is using a subscription based approach similar to react-redux v5 and below and doesn't inherit the problem that the current v6 approach is doing (but also doesn't give you some of the Concurrent React guarantees). We also use the same way of bailing out by state updates so I don't think that's a big difference.

We do, however, use the new Context API only while as older version of react-redux use the legacy context API which, when present anywhere in your React tree, will make everything choose a different code path. So I'd assume that, if you don't use any legacy context APIs, you'd get a net win depending on the project size.

This is of course purely theoretical and you should benchmark your concrete app to find out what solution works for you. Most apps that I've encountered are not bottlenecked by the state propagation implementation.

I'd close this out since there's nothing I can do to prove this to you. Feel free to comment your findings if you're doing some actual benchmarks.

salvoravida commented 5 years ago

6.0.1 to 6.2.1 - refactor - fix Performance https://github.com/reduxjs/react-redux/pull/1201

test it now wih:

"react-redux": "npm:@salvoravida/react-redux@^6.2.1"