Class and Functional Components

Learn the difference between class and functional components.

We'll cover the following

React allows us to make components using both classes and functions. Before React’s Hooks API, only class components could have a state. However, now we can add a state to function components as well. Let’s look at both components, one at a time.

Class components

Class components accept props that can be accessed using this.props. They have a render method that returns HTML. Class components are also called stateful components because they implement logic and state. They also have support for component life cycle methods. The code snippet below shows how a class component is used with React Native.

Get hands-on with 1200+ tech skills courses.