Description
Hi,
This issue is not meant to start a flamewar or to bash this wonderful library. Also, I do not intend to disrespect the contributors of it, but I am looking for some insight and for an open discussion about the usage of hooks in the context of redux.
I'm a huge proponent of hooks as a replacement of the old React class state + lifecycle methods. It's IMO way easier to reason about the flow of data, to identify bugs and to reuse and compose state / functionality with this API.
Regarding react-redux I've always liked the usage of a HoC (connect
) to inject state to props as it nicely decouples the implementation (redux) from the application (accessing data). Now, I understand that the hooks provided by react-redux aren't supposed to be a replacement for connect
but the usage of hooks within the context of Redux feels almost like an antipattern to me.
Hooks does (subjectively) provide a nicer API and reduces boilerplate, but it - IMO - encourages bad design decisions that leads to a more tight coupling of redux and components that reduces usability, testability and violates the SRP. Also, hooks comes with a few potential pitfalls that aren't obvious.
The mitigating factor to the tight coupling is that there often is a de-facto coupling to redux even if there isn't a programmatic one. Also, there is nothing stopping you from creating a hooks based HoC (something like #1065 (which i really like BTW)), but since there is already connect
, what's the point?
I really want to like react-redux hooks and given the widespread adoptation of it amongst my peers I guess there's something I'm missing. So if anyone of you would like to enlighten me and have a productive (though late) discussion regarding this it would be awesome.
Thanks for maintaining this awesome lib!