O'Reilly logo

Progressive Web Apps with React by Scott Domes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

State in React

Every React component has something called state. You can think of this as the configuration of the component at a certain point of time.

Take, for example, a heart icon that turns red when you click on it, as in the case of Twitter. The button has two states: unclicked and clicked. Clicking on the button causes its state, and thus its appearance, to change.

That's the flow in React; user actions or events cause the component state to change, which causes the component's appearance to change.

The preceding statement comes with an enormous helping of "Well, not always…," but it's a useful starting point to understand state:

User event -> State change -> Appearance change

Let's add some state to our LoginContainer, and then go ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required