Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/siddharthkp/use-timeout
Declarative React hook for setTimeout
https://github.com/siddharthkp/use-timeout
Last synced: about 2 months ago
JSON representation
Declarative React hook for setTimeout
- Host: GitHub
- URL: https://github.com/siddharthkp/use-timeout
- Owner: siddharthkp
- License: mit
- Created: 2019-02-04T09:26:52.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T02:17:19.000Z (almost 2 years ago)
- Last Synced: 2024-10-25T11:47:44.499Z (about 2 months ago)
- Language: JavaScript
- Homepage: https://codesandbox.io/s/vqxwwyolxy
- Size: 220 KB
- Stars: 75
- Watchers: 2
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - siddharthkp/use-timeout - Declarative React hook for setTimeout (JavaScript)
README
Declarative React hook for setTimeout
Demo on CodeSandbox
Declarative adaptation of `setTimeout` based on [Dan Abramov's blog post](https://overreacted.io/making-setinterval-declarative-with-react-hooks/) about `setInterval`
#### install
```
npm install use-timeout
```
#### usage
```js
import useTimeout from 'use-timeout'function SimpleExample() {
const [message, setMessage] = useState('changing in 2 seconds...')useTimeout(() => setMessage('changed!'), 2000)
return
{message}
}
```
#### but why?
Long answer long: [overreacted.io/making-setinterval-declarative-with-react-hooks/](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)
#### like it?
:star: this repo
#### license
MIT © [siddharthkp](https://github.com/siddharthkp)