Declarative React hook for setTimeout
Branch: master
Clone or download
Latest commit b8768bc Feb 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.babelrc everything now Feb 4, 2019
.gitignore everything now Feb 4, 2019
LICENSE everything now Feb 4, 2019
README.md everything now Feb 4, 2019
dist.js everything now Feb 4, 2019
index.js everything now Feb 4, 2019
package.json everything now Feb 4, 2019
yarn.lock everything now Feb 4, 2019

README.md



Declarative React hook for setTimeout

Demo on CodeSandbox

 

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?

⭐️ this repo

 

license

MIT © siddharthkp