0

I want a use case example of when react class components are needed for a project over a react functional component and vise versa. I cant seem to understand the difference between the two.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • Class components are discouraged now after hooks has been added – Konrad Oct 09 '22 at 23:19
  • 1
    Some threads: [what is the difference between functional component and class component](/q/35953840), [React functional components vs classical components](/q/38926574), [When to use ES6 class based React components vs. functional ES6 React components?](/q/36097965) – Henry Ecker Oct 09 '22 at 23:23

1 Answers1

0

It’s mostly historical. React components were originally all class components. Function components were introduced in a later version of React. Going forward you should use function components.

ray
  • 26,557
  • 5
  • 28
  • 27