From the course: Learning React Native
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Responding to touches
From the course: Learning React Native
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Responding to touches2m 30s
-
(Locked)
Using a touchable highlight3m 23s
-
(Locked)
Extracting a custom component3m 16s
-
(Locked)
Importing a custom component2m 10s
-
(Locked)
Using a flat list2m 20s
-
(Locked)
Creating a form3m 27s
-
(Locked)
Collecting input4m 26s
-
(Locked)
Creating a custom hook3m 20s
-
(Locked)
-
-
-