Simple useTimer Hook for React
npm install use-simple-timer> Simple useTimer Hook for React
``sh`
npm install use-simple-timer
`sh
import useTimer from 'use-simple-timer';
const [{seconds, setSeconds, toggle, reset, isActive, setIsActive, isPaused, setIsPaused}] = useTimer()
`
`sh
seconds:number -> The seconds that passed.
setSeconds:React.Dispatch
toggle:()=>void -> toggles the isActive variable.
reset:()=>void -> resets the timer(i.e. if seconds is 3, then after calling reset, seconds will be 0. Does not stop the timer).
isActive:boolean -> returns true if timer is active, false if it is stopped. Default = true.
setIsActive:React.Dispatch
isPaused:boolean -> returns true if timer is paused, false if it is not paused. Default = false.
setIsPaused:React.Dispatch
`
`sh``
const [{seconds}] = useTimer(3000) - Now the timer works once every 3 seconds. Default is 1 second if no number is specified.
š¤ Baba Dan Constantin
- Website: Baba Dan Constantin
- Github: @danifullstackengineer
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a āļø if this project helped you!
Copyright Ā© 2022 Baba Dan Constantin.
This project is MIT licensed.
---
_This README was generated with ā¤ļø by readme-md-generator_