From the course: React Native Essential Training

Unlock the full course today

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

Changing UI based on selected numbers

Changing UI based on selected numbers - React Native Tutorial

From the course: React Native Essential Training

Start my 1-month free trial

Changing UI based on selected numbers

- [Instructor] Now that we know that we have a way to handle the press of a number, let's think about the logic behind this press. Every time we press a number, we would like to keep a running sum. And once this running sum is equal or greater than 28, we have two cases to handle. But before we actually handle that logic, let's handle the UI logic. So every time I press a number, what should the UI do? And for this particular game, the UI should show that this number is pressed because I can't actually press it again. Once I press it once, the UI should change to the state of that number, and I can't press it again. Since the UI has to change, that means every time I press the number something has to change on the state somewhere because I need React to re-render the view. So your next question becomes, what should we place on the state? And where should we place that on the state? For example, can I place the value…

Contents