Managing the Component State in React

Learn how to manage component state in React using TypeScript, allowing dynamic updates and rendering.

Introduction to the component state

Each React component can also have what is known as a component state. The difference between a component’s properties and its state is that properties are set and managed by the parent component, but the state is managed by the component itself.

As an example of how we can use component state, let’s update our App component, and set an internal property that will toggle on or off when we click on our button.

To indicate that a React component has a state, we add a second argument to our component definition as follows:

Get hands-on with 1200+ tech skills courses.