Simple Timer Hooks For React Native

A simple React Native hook used to create timers & counters in your app.

How to use it:

1. Install and import the useClock hook.

# NPM
$ npm i react-native-timer-hooks
import React from "react";
import { StyleSheet, View, Text, Button } from 'react-native';
import { useClock } from 'react-native-timer-hooks';

2. Create a basic timer.

const Example = () => {
const [counter, start, pause, reset, isRunning] = useClock(0, 1000, false);
  return (
    <View style={styles.container}>
      <Text>Seconds: {counter}</Text>
      <Button
        onPress={() => {
          isRunning ? pause() : start();
        }}
        title={isRunning ? 'Pause' : 'Start'}
      />
      <Button onPress={() => reset()} title={'reset'} />
    </View>
  );
};

Preview:

Simple Timer Hooks For React Native

Download Details:

Author: samuel3105

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/samuel3105/react-native-timer-hooks

License: MIT

You Might Be Interested In:

Tags:

Add Comment