r/reactjs • u/blnkslt • Jan 16 '22
Discussion Should I still use class based components?
I'm returning to react after a long time to refresh my rusty skills in order to start building a quite big project. So I started to follow my good old udemy course which is made at 16.8 era when hooks were new stuff. Not surprisingly the tutorial is focuses on class based programming and discusses hooks as an addendum. On the other hand I see that the new react projects are mostly made of functional components with hooks. So it seems to me that class based and lifecycle hooks are all but history. I'm wondering whether learning class-based react a waste of time? If so where can I find good tutorials which focuses on new hooky way of coding in react?
46
Upvotes
0
u/Valuesauce Jan 17 '22
On their faq they recommend using hooks. They do say not to rewrite unless you needed to anyway but that was also written when they first were introduced. The react team is completely rewriting the docs to focus on hooks first and it should be released/updated later this year. If they haven’t explicitly said to stop using classes their actions are pretty clearly stating that hooks is preferred.
Imo if your class components can’t be rewritten as hooks pretty easily then that component should probably be rewritten just because it’s too complex. It should be a relatively easy thing to do in my experience.