Skip to Main Content
Beginning React
book

Beginning React

by Andrea Chiarelli
July 2018
Beginner content levelBeginner
96 pages
2h 8m
English
Packt Publishing
Content preview from Beginning React

Changing the State

The event management example that we looked at is very simple, but it only shows the basics of React event management. This example does not involve the state, and its management is straightforward. In many real-world cases, an event causes changes to the application's state, and that means changes to the component's state.

Suppose that, for example, you want to allow the selecting of products from the catalog. To do so, we add the selected property to each product object, as shown in the following array:

[  {"code":"P01",    "name": "Traditional Merlot",    "description": "A bottle of middle weight wine, lower in tannins      (smoother), with a more red-fruited flavor profile.",    "price": 4.5, "selected": false}, {"code":"P02", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Test-Driven React

Test-Driven React

Trevor Burnham
Pro React 16

Pro React 16

Adam Freeman
The React Workshop

The React Workshop

Brandon Richey, Ryan Yu, Endre Vegh, Theofanis Despoudis, Anton Punith, Florian Sloot, Daniel Bugl, Brandan Jones, SudarshanReddy Kurri, David Parker, Cihan Yakar
Learning React

Learning React

Alex Banks, Eve Porcello

Publisher Resources

ISBN: 9781789530520Supplemental Content