Hi Ngan, you would use a class-based component when you need the component to manage its own local state, or if you need the component to utilize lifecycle methods. Technically yes, hooks do allow you maintain local state in a functional component, functional components are declarative style while classes are OOP style.
Most enterprise-based React apps are built with class-based components and they are particularly interested in refactoring their apps to be purely functional components, I still think class-based will be the dominating paradigm going forward because it helps distinguish between between which components are stateful components (class-based) and which are just passed state as a container (functional).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Ngan, you would use a class-based component when you need the component to manage its own local state, or if you need the component to utilize lifecycle methods. Technically yes, hooks do allow you maintain local state in a functional component, functional components are declarative style while classes are OOP style.
Most enterprise-based React apps are built with class-based components and they are particularly interested in refactoring their apps to be purely functional components, I still think class-based will be the dominating paradigm going forward because it helps distinguish between between which components are stateful components (class-based) and which are just passed state as a container (functional).