@qriousgabriel/react-countdown-hook
v1.0.0
Published
A count down hook for React
Downloads
4
Readme
react-countdown-hook
A very simple count down hook for React.
Install
NPM
npm install --save @qriousgabriel/react-countdown-hook
Yarn
yarn add @qriousgabriel/react-countdown-hook
Usage
// Timer.tsx
import * as React from 'react'
import useCountDown from '@qriousgabriel/react-countdown-hook'
export const Timer = () => {
const { counter, pause, resume, isPaused } = useCountDown(120, 1000)
const toggleTimer = () => {
isPaused ? resume() : pause()
}
return (
<React.Fragment>
<div>Counter: {counter}</div>
<button onClick={toggleTimer}>{isPaused ? 'Resume' : 'Pause'}</button>
</React.Fragment>
)
}
License
MIT © qriousgabriel