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
-
Honestly only had a single issue with it, and it was due to the fact I could not edit a parent class… what is giving you issues in useEffect, specifically?
-
Crismon2343yFunctional components are the shit. Now you have one hook where you had 4 lifecycle methods before. And no more HOCs all over the place.
After all, its just a syntax and works in the same why. It really is not that difficult and you can write your components in a much cleaner way.
Please dont be the one that uses class components on a new project, please… -
klutch3893yClass components are fuckin trash. You can do so much more in a lot less code with functional components, hooks, and context.
If it's a legacy project, that's a different story- refactoring a massive app to FCs from Classes without legitimate reasons for doing so isn't recommended obviously, but learning how to leverage useEffect and the other more advanced hooks will save you a LOT of time -
Crismon2343y@klutch Well you can also use functional components on legacy projects if you can bump your react version high enough. You can just drop in FC and use your HOCs on it.
The only class I ever write in React is the Error Boundary. -
klutch3893yMinimum 16.8! I've built many class components myself in the last few years - But now I have a solution in place for anything I'd need classes for, and that fucking rules lol
-
@piratefox well its a complete host of things I have juniors under me that have just started and they find it difficult to understand the difference between the second parameter of the useEffect but they know how to make the same code work with Classes. Then there is this issue where the functional components are kinda difficult to read if not careful everyone follows their own style to name functions its quite difficult to follow the flow for each one. The only reason people prefer functional over class is because of aesthetics and the code being shorter, but hey guys The code is minified regardless and Gzipped later. So having some extra pieces that make things clearer is ok.
-
@Crismon It’s not about being difficult. It’s about too many things to keep track of when using these hooks. Also I prefer HOC’s Render Props etc. They are not that bad once you get to understand those concepts.
-
@klutch To each his own I guess but other than shortening the code time saved is really if done right. And shortening the code doesn’t really have a massive impact on efficiency because the code is minified anyways and gzipped.
-
Crismon2343y@WhatDaCode What do mean of what to keep track of? Every React hook has the idea of an dependency array that you have to keep track of. Other than that you can track if a component rerendered because of a hook in your devTools.
I find it more confusing to keep track of HOCs which are not in my component code but wrap them. I use that very seldomly. I still use render Props all the time, thats not functional components.
The real question is if you want to miss out on all those awesome features that are meant to come in the future that will probably not be supported in Class components. -
@WhatDaCode functional components are not only about that, they tend to also be lighter performance-wise!
I see the issue with juniors, it can be a bit confusing, but you may argue it teaches juniors new skills so 50/50 on it… if you are short on time it can be rough!
As for the naming let me suggest you prettier + either eslint or tslint with custom rules: it takes a little to get started writing custom rules but trust me when I tell you it reduced a LOT the amount of “not following the conventions” in my previous jobs! -
@Crismon I think this falls down to preference here. I feel vice versa. And yeah ofcourse I can use the latest features if required and mandatory.
-
@piratefox I have read the react docs the “performance wise lighter” as suggested depends on the size of the Application. Also thats true I do want to add in rules for Eslint and prettier thats in progress and intend to get up and running. The deadlines are always short in India, Its always as soon as possible.
Related Rants
-
devTea13Microsoft Fucking Sharepoint for development
-
llcamp19Donโt fall for the hype. Software is not only FAANG, ridiculous perks and fancy corporate offices. Itโs a ...
-
bittersweet20Every single diagramming tool. All the SaaS ones are either way too limited in function, or proprietary vendo...
Its not a product, but personal opinion working on react for the last 4 years and one thing is for sure Reacts functional components are shit to use compared to the class components. Specifically useEffect. React was never supposed to be written in a functional way when it first launched.
rant
wk268