Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
kiki352484yOn an unrelated note I rate this rant’s tags decent but sometimes something feels off. Overall strong 7/10 👍
-
10Dev28994yI love my class components.
As long as you aren't doing anything with state, functional is the way to go
But it just feels more intuitive working with state in classes than in functions, and I've never had problems 'this' in my time with React
I feel like hooks are a way to bring React to people who don't fully understand JavaScript, and don't really want to learn the oddities of the language -
@10Dev I feel like that’s a harsh assessment. I know the oddities of the language better than most and still prefer functional components with hooks over class components. I definitely prefer them over prop drilling. Remember prop drilling? I hate prop drilling.
-
@10Dev I love functional components, less boilerplate and the components seem more explicit as far as what they are doing.
I'm not sure I ever learned anything about JavaScript because I used a class component. -
@AmyShackles
There are people who understand separating data from functions, and people who like to watch the world burn. -
Hook are fun, I’m new to react but I’d much rather deal with useState and not have to worry about complex life cycle code like component did mount, didn’t mount, almost mounted but passed out
-
Voxera115854y@10Dev I prefer hooks since it results in cleaner, and smaller, code in my opinion.
And I have been using js extensively since 1995 when Netscape released the first version ;) -
devJs13314yLifecycle methods were easy to use, it took you like 10 minutes to read the friggin docs.
Classes are ok, easier to test, but I also prefer hooks as code is cleaner. -
@theabbie If it's your preference then there's nothing wrong with that at all - but I'm not sure it's been considered the "new normal" for about 20 years :-)
-
@AlmondSauce No, Reusable components and stuff, It is definitely more scalable than functional programming, if I understand what functional programming means
-
You can still reap the benefits of oop like encapsulation and separation of concerns with hooks and you won’t have to deal with extra typing and code fat. Lifecycle methods weren’t hard for me but add complexity I don’t need
-
@theabbie you can reuse functional components by importing them. Functional components are still objects and you can think of their props or parameters as object fields. I’m not sure how far you can really go with object oriented programming in react like using interfaces and polymorphism like in java
-
I'm still a beginner learning react. I've seen people use and teach class and function based components. Is there any significant difference between them why one is preferred over the other? Like performance wise etc?
-
@firecracker Not really. It’s more of a preference and what you feel is easier for people reading your code.
-
Functional vs OOP is not a competition. There is a time and place to use either. A lot of things that react does benefits from using pure functions. Actually that applies to almost anything on the browser these days. But that's not taking away from OOP.
Related Rants
-
bittersweet23My mom died when I was 7, after which my dad bought me a Commodore 64 so I had something to lose myself in dur...
-
Root30I’m kind of pissy, so let’s get into this. My apologies though: it’s kind of scattered. Family support?...
-
Linux10No, my family did not support me. They complained about everything. From how "Python was demonic" to how "Wo...
In React, OOP is now the old way of approaching react.js everybody doing functional programming/functional components.. this that the future ???
question
wk227