Creating a Timer
Now that we're done with the Stopwatch screen, it's time to open the Timer.js
file and work on our Timer screen. We should dive right in, remove everything, and start importing everything we need for this.
First of all, we all know that at the end of a Timer cycle, there's always a sound playing, letting you know that it has stopped. For that, we need a new package called expo-av
. This is an Expo package for dealing with audio. It is quite easy to use, so let's begin by installing it into our project by using the following command:
expo install expo-av
Now that we have installed this, we can start importing everything we'll need to build this component. We'll need a timer component that is quite similar to the Stopwatch. We'll also need to use intervals and date objects to calculate everything, so useEffect
and useState
will be imperative for our screen.
The difference is that we'll need to let the user input exactly...