8

Dealing with State in React

Up to this point, the components we’ve created have been stateless. They have properties (a.k.a. props) that are passed in from their parent, but nothing (usually) changes about them once the components come alive. Your properties are considered immutable once they’ve been set. For many interactive scenarios, you don’t want that. You want to be able to change aspects of your components as a result of some user interaction (or some data getting returned from a server or a billion other things).

We need another way to store data on a component that goes beyond properties. We need a way to store data that can be changed. What we need is something known as state. In this chapter, you learn all about state and how ...

Get Learning React: A Hands-On Guide to Building Web Applications Using React and Redux, Second edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.