1.0.6 ā€¢ Published 2 years ago

use-simple-timer v1.0.6

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

Simple useTimer Hook for React

šŸ  Homepage

Install

npm install use-simple-timer

Usage

import useTimer from 'use-simple-timer';

const [{seconds, setSeconds, toggle, reset, isActive, setIsActive, isPaused, setIsPaused}] = useTimer()

Available variables

seconds:number -> The seconds that passed.

setSeconds:React.Dispatch<React.SetStateAction<number>> -> Sets the seconds to a value(use milliseconds, i.e. if you want to set the seconds to 3, then setSeconds(3000)).

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<React.SetStateAction<boolean>> -> Sets isActive.

isPaused:boolean -> returns true if timer is paused, false if it is not paused. Default = false.

setIsPaused:React.Dispatch<React.SetStateAction<boolean>> -> Sets isPaused.

Modify the time for the timer

const [{seconds}] = useTimer(3000) - Now the timer works once every 3 seconds. Default is 1 second if no number is specified.

Author

šŸ‘¤ Baba Dan Constantin

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2022 Baba Dan Constantin. This project is MIT licensed.


This README was generated with ā¤ļø by readme-md-generator

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago