From the course: React Native Essential Training

Unlock the full course today

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

Using TouchableOpacity for press events

Using TouchableOpacity for press events - React Native Tutorial

From the course: React Native Essential Training

Start my 1-month free trial

Using TouchableOpacity for press events

- [Instructor] Our next step is to click these numbers and start to think about what should happen when we do. Now, these numbers are so far presented here with just a text element. And since we're going to click on that text element and that click is potentially going to need the random number value. Since it's going to trigger a computation of the (mumbles) that's our sign that we need a component to represent every clickable number. Whenever you have something that you need to click on and you need the value related to that thing that you click on, it's your sign that you need a component. The other sign that we actually needed a component here is that we are rendering six similar things, they're all random numbers. They share markup, they share style and they're also now going to share behavior. Whenever we click on each of these six, the behavior is basically the same. These are our signs that we need a component…

Contents