Skip to content

behnamazimi/react-random-interval-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Random Interval Hook

Make an interval with random time delay specified with min and max delay between each call.

Installation

Using npm:

npm install react-random-interval-hook

Using yarn:

yarn add react-random-interval-hook  

Exmaple

import useRandomInterval from "react-random-interval-hook";

const interval = useRandomInterval((stop) => {
  // do what you want
  
  if (stopCondition) {
    stop();
  }
}, 1000, 2000); // interval between 1000 and 2000 ms

stop method also returns by the hook, you can stop interval manually like this.

if(stopCondition)
  interval.stop();

License

MIT

About

Make an interval with random time delay specified with min and max delay between each call.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published