React Native Create Custom Countdown Timer for Android iOS Tutorial

A countdown timer is a reverse virtual clock which runs in reversible mode. We have seen the Countdown Timer in many mobile applications where after a certain time a particular task executed. This happens when the Countdown Timer reaches to Zero value. In react native we can make beautiful fully custom Countdown Timer using react-native-countdown-component NPM library. This library comes with many customization features also with on count down timer finish function calling feature. So let’s get started .

Contents in this project React Native Create Custom Countdown Timer for Android iOS Tutorial:

1. Open your react native project folder in command prompt or Terminal & execute below command to install the react-native-countdown-component library.

Screenshot of CMD:


2. Open your project’s App.js file and Import StyleSheet, View, Text, Platform and Alert component in your project.

3. Import Countdown component from react-native-countdown-component library in your project.

4. Create 2 function named as onDoneCountdown() and onPressCountdown().

onDoneCountdown : Calls when countdown finish.

onPressCountdown : Calls when user press the countdown component.

5. Create Countdown component in render’s return block in Root View component.

until : Here 600 represents 600 seconds so it means 10 minutes. It will calculate seconds automatically into minutes and if you will give seconds more than 60 minutes then it will convert them into hours.

onFinish : Calls on countdown finish.

onPress : Calls on count down press event.

size : Size of countdown component

There are 14 different type of props available in Countdown timer library. You can learn about them here on its official GitHub page.

6. Creating style.

7. Complete source code for App.js file class.

Screenshots:

Create Custom Countdown Timer for Android iOS Tutorial