From the course: React Native Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Working with timers - React Native Tutorial
From the course: React Native Essential Training
Working with timers
- [Instructor] Implementing a countdown to track the seconds spent playing this game is easy. We can just use a regular interval. The question is do we need to put this information on the state or not? And to answer that, we need to answer another question, which is do we need to display anything in the UI while the timer is ticking? We should probably do that. We should probably display these remaining seconds. Like you start with 10 seconds and then the counter ticks that down every second and we should display the number of remaining seconds in the UI, which means we need to put this number on the state of the game. Let's do that. We'll start with remainingSeconds. I think that's a good name. And we start with 10. Of course, we can make this configurable if we need to, if you want to make the game harder. Just like randomNumberCount, we can make this game receive another property and maybe a good name for this…
Contents
-
-
-
-
-
(Locked)
Introduction and preview42s
-
(Locked)
Initializing the TargetSum app4m 36s
-
(Locked)
Configuring ESLint1m 47s
-
The game component with a random target3m 54s
-
(Locked)
Generating the random play numbers9m 41s
-
(Locked)
Styling the random play numbers2m 23s
-
(Locked)
Using TouchableOpacity for press events6m 17s
-
(Locked)
Changing UI based on selected numbers7m 31s
-
(Locked)
Adding shared behavior to numbers6m 21s
-
(Locked)
Using React DevTools with React Native4m 24s
-
(Locked)
Computing dynamic values where needed5m 14s
-
(Locked)
Changing UI based on game status4m 5s
-
(Locked)
Working with timers6m 16s
-
(Locked)
Caching to optimize computable values8m
-
(Locked)
Remounting a component to reset it7m 30s
-
(Locked)
-
-
-
-