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

2 Comments

  1. hi sir finally my react native app publish on app store , whithout you its not possible to me Big Thank you.https://itunes.apple.com/us/app/n%C3%A9metorsz%C3%A1gi-magyarok/id1434670777?ls=1&mt=8

    • Thanks for showing this gesture Rahul :). It will be a Good thing for me that you are giving me this respect 🙂 & the app is amazing .

Leave a Reply

Your email address will not be published. Required fields are marked *