Why i won't use React Hooks
Truong Hoang Dung

Truong Hoang Dung @revskill10

About: I hate technical debts, very much. Learning to clean debt out of my life.

Joined:
Aug 2, 2018

Why i won't use React Hooks

Publish Date: Jan 21 '19
15 17

I'm passionate about ReactJS, because of its declarative programming model.

That means, in React,

view = function(state)

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

With separate function for behaviour, you can easily reuse, unit test, and package it.

With React Hooks, what i have to do is to mess side-effects within the component.

It's not good to me.
It's not simple to debug.
It's not simple to reuse the behaviour.
It's not easy to unit test the behaviour.

That's why i would say NO to React hooks, because i prefer simplicity to magic.
I'm a simple developer, not a magician trying to understand wtf is going on with my production code.

Comments 17 total

  • Ghost
    GhostJan 21, 2019

    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.

    • Truong Hoang Dung
      Truong Hoang DungJan 21, 2019

      Agree. I found no need for React Hooks.

    • Tran Dinh Trung
      Tran Dinh TrungJul 8, 2019

      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.

  • Abhijit
    AbhijitJan 21, 2019

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

    How do you do it then?

    • Truong Hoang Dung
      Truong Hoang DungJan 21, 2019

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

      • Abhijit
        AbhijitJan 21, 2019

        Like redux?

        • Truong Hoang Dung
          Truong Hoang DungJan 21, 2019

          No need for redux.
          You can read more about HOC and render props in ReactJS guide.

          • Abhijit
            AbhijitJan 21, 2019

            Alright. Thank you!

  • Jaff Parker
    Jaff ParkerJan 21, 2019

    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.

  • Jamal Al
    Jamal AlJan 22, 2019

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

  • АнонимMar 22, 2019

    [deleted]

    • Truong Hoang Dung
      Truong Hoang DungMar 22, 2019

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

      • Douglas Schmidt
        Douglas SchmidtJun 11, 2019

        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.
        BR.

  • Jaff Parker
    Jaff ParkerJun 17, 2019

    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

  • Louiszen
    LouiszenSep 7, 2021

    I think you will be happy using react hook only if you are working as a team of only one person. I have seen too many hook lovers without a good fundamental skill of programming, just like making a one-page website, err.... I meant all JS code in one page, one single file.

  • Tabatha Pradier
    Tabatha PradierJan 21, 2025

    I Totally agree with you!!!
    It is actually one of the most precious lessions I learned with my mentor.

    I'm currently browsing the web to find a way to understand and solve the problem with my app, where my react component is not tracking the route change when a post request is succesfull (probably because react router is storing cache).

    So the post request is http 201, it closes the modal when sucessfull and change to it's parent route (something like from /customers/new to /customers), but do not refresh the data display with the new register in db.

Add comment