1.0.12 • Published 3 years ago

react-time-hooks v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

PropTypeDescription
timeThis is initial time , Timer or Count down start counting at this valueMandetory

useTimer Options

PropTypeDescriptionDefault
countOnFocusBooleanOptional. if true its stop counting when page is not focusfalse,
intervalNumberOptional. the interval of counter in seconds1,
autoStartBooleanOptional. if true it start counting as hooks loadedtrue,
stop_timeNumberOptional. if passing number it stop counting on that number = null,

useTimer Options

PropTypeDescriptionDefault
countOnFocusBooleanOptional. if true its stop counting when page is not focusfalse,
intervalNumberOptional. the interval of counter in seconds1,
autoStartBooleanOptional. if true it start counting as hooks loadedtrue,
stop_timeNumberOptional. if passing number it stop counting on that number = null,

Suggestions?

Open Issues. Submit PRs.

License

MIT © Amirnajafi

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago