7

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.

Comments
  • 2
    definately it can get a bit confusing, but in the end no one likes classes
  • 2
    @EpicofGilgamesh That’s where you are wrong my man.
  • 0
    ๐Ÿ‘ Angular (ngx) ๐Ÿ‘
  • 1
    @Cyanide where am i wrong??
  • 1
    I prefer functional components way more than class components....
  • 0
    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?
  • 1
    @EpicofGilgamesh That “no one” likes classes.
  • 3
    Functional 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…
  • 2
    Class 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
  • 1
    Fuck stupid ass Classes. Learning functional components take no time.
  • 1
    @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.
  • 0
    Minimum 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
  • 0
  • 0
    @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.
  • 0
    @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.
  • 0
    @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.
  • 1
    @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.
  • 1
    @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!
  • 1
    @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.
  • 1
    @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.
Add Comment