1.0.2 • Published 5 years ago

use-timed-index v1.0.2

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

useTimedIndex

Get an index value auto-incremented by 1 every X ms.

What ?

useTimedIndex is a react hook that outputs a number starting at 0 and incrementing over time. The two arguments are the interval by which the index is incremented and a delay that pause the increment after each step.

Example

function App() {
  // Update the index value by 1 about every 1500ms
  const index = useTimedIndex(1500);

  return <div>{index}</div>
}

Install

Has react as --peer dependency.

yarn add use-timed-index

or

npm i use-timed-index

Created by

License

MIT