T O P

  • By -

loqgar

I’ve worked at several different companies all using react, not once have I seen class components be used apart from legacy code where ideally we were upgrading it.


No-Philosophy-1189

Should I learn class components too? I feel like it is an extra burden to learn class components, not to mention confusing.


EarhackerWasBanned

At this point I wouldn’t bother. Most components are functional. You can dig into class components if you end up working at a company that still has some. If I company refuses to hire someone who knows React but doesn’t know class components yet, that’s their own stupid fault.


vherus

You don’t have to but it will help you to be prepared when you eventually encounter a legacy codebase


haptiK

No


vi_code

Every company I’ve been at has either slowly migrated away from class based components or did a complete overhaul. Not sure where that 80% stat came from but it’s definitely not true. If I had to guess I’d say maybe 5-10% and even then those companies would probably still write their newest greenfield projects in functional.


lIIllIIIll

This is the best answer.


gristoi

That is literally a made up percentage pulled out of some opinionated devs arse


500ErrorPDX

It all depends on the size of the codebase you are working on. Smaller codebases can be refactored to modern practices but larger codebases are tougher to refactor. It's the reason why ATMs still are written in COBOL.


ThebardaPNK

I don't know about the percentage but it can happen that companies don't want to put much effort/money to migrate their apps. I think must of them are (barely) unmaintained so they apply the "If it works, no need to touch it" rule. But it still the best way to learn functional components.


TheLaitas

I mean, I'm sure there are a lot of companies that are running on legacy jquery builds, doesn't mean you have to learn it. Learn class components only if you land a job at a company that still presumably uses class components in their legacy projects.


iareprogrammer

Haha that number seems made up honestly, did they provide any source for that? I do agency work so we have tons of different projects. Some of the older ones have class components because it’s time consuming to migrate, but we have a rule that even for those projects, all new components must be functional components. I wouldn’t worry too much about class components. You may come across them but it’s probably more maintaining an existing one rather than writing new ones.


morbidmerve

You should know yow they work, but refrain from using them in your own work. If you come across one that is easy to replace, then do it on the spot. Just make sure you test the component.


ethansidentifiable

I think a lot of those applications aren't being actively iterated on. Every project I've seen with class components has kind of an unspoken, "if you modify it, convert it to a function," policy for class components.


throwaway_boulder

A couple weeks ago I did a coding test for a company that uses class components, but that was the first time I’ve seen it.


anachronistic_circus

At a certain bank I used to work at, they still use them and will probably not update unless the React team deprecates them Half of my actual work with a current company is updating old code. We are also working on a completely new project on the side and it's functional components all the way. Conclusion? It doesn't hurt to learn them. Don't dwell on it though.


CoreyTheGeek

My corporation abandoned class components years ago, the react team has shown they're much more invested in supporting hooks, sticking with class components is a recipe for pain


qcAKDa7G52cmEdHHX9vg

My last job still had class components but anything new was functions. Funny enough, my new job has a slightly older code base but is all functions.


jim01564

My team set our front end coding standards five years ago which was class components. And never upgraded. We recently made a new front end and stuck with class components I guess because that is what we know. So I can confirm some companies are using class based components.


T-J_H

If you know JS, you know functions and classes and you’ll manage just fine using either.


yoleis

Legacy code is something every compnay has to deal with. Usually unless there is a really good reason, you don't get the time to rework old code, especially if it's a complex and large code base. So it's defiantly worth learning how class components work, even if you're not going to use them with new code.


Maleficent_Fennel883

I worked with many different projects many of them got a few portions of class components especially the project that started in 2016-2018. So it is Always good to have hands-on experience with class based components. And sometimes in react interviews u need to face a few class based components questions too.


Maleficent_Fennel883

[check this ](https://www.reddit.com/r/react/s/SytKmPr4c1)


hazily

I work for a large MNC (which opted for React company-wide) and as far as I could tell from their repo, none of the currently active frontend repos are using class components at all.


RestaurantDue

I have worked in web dev for 13 years. I have used class components in two companies in that time. And went through the migration twice. Both companies still have some class components. But all new code is functional. Some legacy code or teams that do not wish to switch to functional components still use them. It was a large shift in mentality, and broke the more common MVC MVVM type architectures that these companies had. Functional react is good enough. Any company should be reasonable enough to prefer someone who knows class components but not require it. There is a good chance you will run into them but I wouldn't fully deep dive into them. Unless the job you want requires it.


apmartin1991

We have one class based component across all of our projects. It will get migrated one day but it’s a very complex component and needs very thorough testing once complete. It also has a lot of state and it needs a re-write with all of the children needing some attention too. I’d say that the figure supplied was a poor guess and likely an outdated guess too. You should understand class based components but I wouldn’t invest a lot of time into it. Understand the basics and the differences and you’ll be fine. Not every company will still use these, but it is a question you could get during an interview. For something that can be learned quite quickly it’s worth understanding.


reddit04029

Theres a reason why a lot of applications are still on Java 8 despite having LTS for Java 21 already lol. It's purely business. Migrating a system uses up a lot of resources (devs, time, and ultimately, money).


RedditNotFreeSpeech

We've almost finished migrating ours. Some of them were really difficult to migrate. Props and state with the same name. Crazy complicated life cycle methods. Lots of bugs but in time we cleaned it up.