8000 GitHub - siddharthkp/use-timeout: Declarative React hook for setTimeout
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

siddharthkp/use-timeout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



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

About

Declarative React hook for setTimeout

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0