...

/

Storing State in React Components

Storing State in React Components

In this lesson we will go over the concept of State in React Components and how state updates trigger rendering of the component.

In the previous lesson, we learned how to handle user interactions, but we didn’t store the event value. Let’s re-examine the code that we saw in the last lesson.

MyInput should handle value on it's own somehow, but turns out that we can't store anything within a function, so we handle it outside of MyInput. We have intentionally discussed functions so far to go over the basics. Now we will introduce you to a full-blown React Component that can store values as well.

The way to define such a React Component is using class.

class is also a part of ES6, and unlike functions, it can store data. We will use it to our advantage to simplify user interactions handling.

Let's create a basic class and ...

Access this course and 1400+ top-rated courses and projects.