Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React functional components vs class components

I am a beginner in React learning it for the last 3 months, However, the way to implement components has split into 2 kinds functional and class. As of 2021 which path to advance in learning, functional Style or class style components.

  • How will the development approach will be adapted in the long run maybe next 5 years
  • Based on the style I can focus on design pattern and architecture style for that particular component style.
like image 202
siva charan Avatar asked Jun 12 '26 23:06

siva charan


1 Answers

For the long run, you should focus on functional components, as react team has suggested to use functional components with hooks to manage the state for component.

But that does not mean you should completely ignore class components. The reason is in professional life you may come up with the code base that was written before the introduction of hooks using class components and you are not allowed to refactor it to functional components ( there can be various reasons of not doing that) in that case your knowledge about class components will come in handy.

like image 126
Mudassar hassan Avatar answered Jun 15 '26 22:06

Mudassar hassan