1.0.2 • Published 4 years ago
@ascendum/use-interval v1.0.2
react-use-interval
This is an customized version of the react hook for setting an interval as posted on overreacted.io.
Install
npm install --save @ascendum/use-interval
Usage
import as React from 'react'
import { useInterval } from 'react-use-interval'
const MyComponent = () => {
const {
toggleRunning,
isRunning
} = useInterval(() => {
// Do whatever magic you wish here.
}, 1000);
return (
<div>
<button onClick={toggleRunning}>
{isRunning ? 'Paused' : 'Resume'}
</button>
</div>
);
}
License
MIT