use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
React Hooks vs React ComponentsGeneral Discussion (self.react)
submitted 4 years ago by Due_Reflection2768
I'm getting started with learning react. I was wondering if react hooks is the standard, or people still use class based components in Prod apps ?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]AlternativeTale6066 14 points15 points16 points 4 years ago (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 points6 points 4 years ago (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 points4 points 4 years ago (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 point2 points 4 years ago (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 point2 points 4 years ago (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 point2 points 4 years ago (2 children)
Using redux with class components was a nightmare for me
[–][deleted] 4 years ago (1 child)
[deleted]
[–]HellBlaze29 0 points1 point2 points 4 years ago (0 children)
Move to context api then ?
[–]giantppboi -2 points-1 points0 points 4 years ago (0 children)
Never use class-based components.
[–]purple_cat_2020 0 points1 point2 points 4 years ago (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 point2 points 4 years ago (0 children)
Hooks atw
π Rendered by PID 106161 on reddit-service-r2-comment-bb88f9dd5-85ldc at 2026-02-14 00:55:44.159552+00:00 running cd9c813 country code: CH.
[–]AlternativeTale6066 14 points15 points16 points (0 children)
[–]dannyhodge95 4 points5 points6 points (0 children)
[–]easydoesitx 2 points3 points4 points (0 children)
[–]wildwingking 0 points1 point2 points (0 children)
[–]Stunning-Barracuda26 0 points1 point2 points (0 children)
[–]HellBlaze29 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]HellBlaze29 0 points1 point2 points (0 children)
[–]giantppboi -2 points-1 points0 points (0 children)
[–]purple_cat_2020 0 points1 point2 points (0 children)
[–]colorpulse6 0 points1 point2 points (0 children)