react-time-hooks

1.0.12 • Public • Published

React | React-native Time hooks

NPM Version

Time hooks help you to use timer and countdown hook in your react and react-native projects
its so lightway and fast
it reduce developing time and prevent to to define any intervals and functions for it

The package is both React and React-native compatible.

Installation

$ npm install --save react-time-hooks or

$ yarn add react-time-hooks

Prerequisites

Time hook has no requirement dependencies

Usage

How to use it:

import React from 'react';
import {useCountDown , useTimer} from 'react-time-hooks'


/* default options 
    {
        countOnFocus = false,
        interval = 1,
        autoStart = true,
        stop_time = null,
    }
*/ 


const Timer = () => {
    const options =  {} 
    const {time , play , reset , pause} = useTimer(0 , options)
    console.log(time)
    render() {
        return ();
    }
}

const CountDown = () => {
    const options =  {} 
    const {time , play , reset , pause} = useCountDown(60 , options)
    console.log(time)
    render() {
        return ();
    }
}

Default time

Prop Type Description
time This is initial time , Timer or Count down start counting at this value Mandetory

useTimer Options

Prop Type Description Default
countOnFocus Boolean Optional. if true its stop counting when page is not focus false,
interval Number Optional. the interval of counter in seconds 1,
autoStart Boolean Optional. if true it start counting as hooks loaded true,
stop_time Number Optional. if passing number it stop counting on that number = null,

useTimer Options

Prop Type Description Default
countOnFocus Boolean Optional. if true its stop counting when page is not focus false,
interval Number Optional. the interval of counter in seconds 1,
autoStart Boolean Optional. if true it start counting as hooks loaded true,
stop_time Number Optional. if passing number it stop counting on that number = null,

Suggestions?

Open Issues. Submit PRs.

License

MIT © Amirnajafi

Readme

Keywords

none

Package Sidebar

Install

npm i react-time-hooks

Weekly Downloads

1

Version

1.0.12

License

MIT

Unpacked Size

29.5 kB

Total Files

10

Last publish

Collaborators

  • amirnajafi