Chapter 4. State

While it is great that Barry the otter is getting some time to shine, all the otters should have equal opportunities for fame. Your app currently listens for user events and responds by logging the name of the otter that the user clicks. In this chapter, you will finish up Ottergram by adding state to keep track of and display the featured otter.

This chapter introduces React hooks, a powerful tool for managing state in a component. You will continue to learn about hooks throughout this book, so do not worry about mastering them right away. In this chapter, you will focus on using the useState hook to manage a component’s state.

By the end of this chapter, your Ottergram application will be complete (Figure 4.1, “Completed Ottergram” ...

Get React Programming: The Big Nerd Ranch Guide 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.