1.1.0 • Published 5 years ago

use-timeout v1.1.0

Weekly downloads
1,657
License
MIT
Repository
github
Last release
5 years ago

 

Declarative adaptation of setTimeout based on Dan Abramov's blog post about setInterval

install

npm install use-timeout

 

usage

import useTimeout from 'use-timeout'

function SimpleExample() {
  const [message, setMessage] = useState('changing in 2 seconds...')

  useTimeout(() => setMessage('changed!'), 2000)

  return <div>{message}</div>
}

 

but why?

Long answer long: overreacted.io/making-setinterval-declarative-with-react-hooks/

like it?

:star: this repo

 

license

MIT © siddharthkp