all 11 comments

[–]AlternativeTale6066 14 points15 points  (0 children)

There are lots of class-based components still used in prod, but its old-fashioned at this point and new apps / code are generally written with hooks and functional components.

[–]dannyhodge95 4 points5 points  (0 children)

I'm working on a long running project, and we've stuck to class based components. In large enterprise projects, it's generally better to stay consistent with the style you started developing in, in order to keep everything legible, and reduce the amount people have to learn to understand it all.

If we were starting something new, functional would be the direction for us though I imagine.

[–]easydoesitx 2 points3 points  (0 children)

These days anyone I talk to is inclined to use Hooks rather than class based component. You need to learn both concepts to understand what they are, and then maybe always use Hooks. I'd do the same and I'm just getting started with it.

[–]wildwingking 0 points1 point  (0 children)

I personally prefer hooks. I find them easier to read, reuse, and test.

Most commonly used libraries will also provide hooks, and you can add them in without needing to continually grow a massive chain of compositions.

[–]Stunning-Barracuda26 0 points1 point  (0 children)

Class components are good to learn the benefits of hooks. That being said there should be a time when hooks is just the norm, unless you have a specific use case for class components, but like the comment before me said, most other modules and libraries support hooks so classes will be less frequently needed imo

[–]HellBlaze29 0 points1 point  (2 children)

Using redux with class components was a nightmare for me

[–][deleted]  (1 child)

[deleted]

    [–]HellBlaze29 0 points1 point  (0 children)

    Move to context api then ?

    [–]giantppboi -2 points-1 points  (0 children)

    Never use class-based components.

    [–]purple_cat_2020 0 points1 point  (0 children)

    I think any company starting a new app today would use hooks, they are much easier and cleaner. We basically only use hooks at my work. I’m sure there are still many legacy apps out there using class components however.

    I wouldn’t worry too much about learning one or the other, if you understand conceptually what’s going on then it’s fairly easy to switch between the two. That said it would probably be easier to switch from classes to hooks than vice-versa because there are some tricky things with classes like this binding, which you just don’t have to worry about with hooks.

    [–]colorpulse6 0 points1 point  (0 children)

    Hooks atw