In React are Classes Redundant / Legacy

I am using functional components, hooks such as useEffect , useContext and contexts in react. It seems that people mainly use classes to manage state in React. Would I still need to use classes and if so what type of problem would I be solving by using classes where I am managing state in contexts.

1 Like

I would only use classes in those instances where useEffect takes away the precise control over the different life cycle method implementations (shouldComponentUpdate, componentDidMount, etc); I have not yet encountered such case but maybe there is for you?

Also remember you can create custom hooks in case you need more functionality. There’s even new hooks like useTransition and such. As for state management; most serious projects use Redux or Mobx.

1 Like

You can do anything using functions that you would use classes for except error boundaries, so it’s unlikely you need to use them outside of that one extremely specific case.