From the course: Learning React Native

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Responding to touches

Responding to touches

From the course: Learning React Native

Start my 1-month free trial

Responding to touches

- Thus far, we've learned how to create and layout user interfaces. It's time to learn how to interact with them. We already have a user interface laid out. So we have a container view, and it contains two text elements. Each of these text elements are styled like buttons, and they're being displayed in a column, which means that each of these text buttons are listed vertically on the screen. We want to make this user interface interactive. So, when a user presses either of these buttons, we want to see the background color change. And for that, we're going to need to useState. useState is a special kind of function that ships with React. It's called a Hook. And we use it to hook functionality up to our components. In this case, we want to save the value for the background color and state, and we also want to be able to change that color. So both the background color and a function to change the background color can be…

Contents