React offers two types of components that offer ample flexibility for all use cases. These are given below:
Class Component: A class component is subclassed from the component class in React. A class component offers several out-of-the-box features. For instance, they let you store the local state. They also allow you to create lifecycle hooks, which will be covered later in the course.
How to choose between class and function components
Although class components, as a syntax, is still in use, function components, coupled with the super-powerful Hooks API, offer a cleaner and simpler syntax in the long run and are probably a better choice. Your code is more readable and easier to test. Having said that, you can still use class components, and we will use them throughout this course in conjunction with function components.
Note: Class components offer built-in support for Local state & lifecycle methods.