Interactivity, State, and Hooks

At this point, React has taken over part of our page and is drawing the seats (although if you’ve looked at the before and after, you’ll see that it was color-coding used tickets and it’s not anymore, we’ll bring that back in Chapter 11, ​Managing State in React​). This is nice enough, but we’d like it to, you know, react to something. We’d like to have a little interactivity.

In React, you can use JSX to specify event handlers on React elements in much the same way you would when writing old-school JavaScript embedded in HTML. The problem is how to make changes to our components as a result of those events. As mentioned, the props we pass into each component are immutable, which means if we want ...

Get Modern Front-End Development for Rails, 2nd 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.