Why i won't use React Hooks

Truong Hoang Dung on January 21, 2019

I'm passionate about ReactJS, because of its declarative programming model. That means, in React, view = function(state) That's why i nev... [Read Full]
markdown guide

I can understand your concerns. Though at the same time, hooks are just an upgrade for the lifecycle functions of class components or the HOC's, but they make it simpler, so if you used those, there's no reason you shouldn't use hooks. I find that hooks look clearer than HOC's or lifecycle functions (HOC's would just always confuse me when I have to compose them, especially when I'd try to create props typings).

I get though that you want to keep your components as much functional as possible. Personally, I started separating my components into containers and views. Views have nothing async, zero side effects, just props => ReactElement. All the data loading and state management and side effects happen in containers. Even when I switch to hooks, it will stay that way.


that's interesting because I always find HOC a cleaner abstraction. Take for example accessing context, the HOC way (such as in recompose) is seen as a form of dependency inversion, which is one of the SOLID principles. The hooks way (and in fact all of the THREE official ways) can be seen as some form of the service locator antipattern.

HOCs let you stay in the simple mental model of view = component(props). When you want to do anything more than that like effects or injecting a context, you do it outside of said component. HOCs make it very easy to unit test and eliminate containers just like hooks.

I do see the need for hooks for low-level libraries (primitive-components-level), it enables a high level of composition without the downside of a bloated component tree as seen in HOCs. For application-level composition, I prefer HOCs though.


I guess that's okay, it's exactly why the React team isn't making classes and HOC's go away :) Personally, I feel that hooks are more in the "spirit of React", but at the same time, the spirit of React is to have more than 1 way to do things, so this is just some healthy variety


I didn't get familiar with hooks, but it seems React team is sometimes pushing it too far, the need to innovate, and the question remains, whether there was really a need for it, or not.


Couldn't agree more. Sometimes, I wonder if they just add the hooks just for the sake of making it different and stand out from other libraries out there.


Yet you have a post on 'A React Hook for universal routing' xD
yeah seems like React team is stretching it too far with react hooks . not a fan YET :)


Yeah, i was wrong at the time of the post. I comeback and retry and i was hooked :P


Your article is well ranked on "react hooks community reaction" (yes, I did search for that before joining the band wagon). So, I think you could update this article with your newer finding about react hooks.


That's why i never mess React Component with side-effects, like ajax request or state.

How do you do it then?


You can use a HOC (Higher order component) to reuse behaviour, or using Render Props pattern.


Totally agree with. I also posted a question against it.

code of conduct - report abuse