@teneff/react-debounce
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@teneff/react-debounce", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "React Debounce Component", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -24,2 +24,5 @@ # React <Debounce /> Component | ||
## Live Demo | ||
[![codesandbox-img]][codesandbox-url] | ||
## Usage | ||
@@ -31,11 +34,10 @@ | ||
class MyComponent extends React.Component { | ||
handleClick = () => { | ||
console.info("event handler will be executed once after multiple clicks"); | ||
}; | ||
handleClick = e => { | ||
console.info(e); | ||
} | ||
handleKeyUp = value => { | ||
console.info("event handler will be executed when you stop typing", value); | ||
}; | ||
handleKeyUp = e => { | ||
console.info('event handler will be executed when you stop typing', e); | ||
} | ||
render() { | ||
@@ -45,15 +47,15 @@ return ( | ||
<Debounce callback={this.handleClick} delay={300}> | ||
{onClick => { | ||
<button onClick={onClick}> | ||
click me, wait, profit | ||
</button> | ||
}} | ||
{onClick => <button onClick={onClick}>click me, wait, profit</button>} | ||
</Debounce> | ||
<Debounce callback={this.handleKeyUp} delay={500}> | ||
{onKeyUp => { | ||
<input onKeyUp={onKeyUp} value="" placeholder="Start typing..." /> | ||
}} | ||
{onKeyUp => ( | ||
<input | ||
type="text" | ||
onKeyUp={e => onKeyUp(e.target.value)} | ||
placeholder="Start typing..." | ||
/> | ||
)} | ||
</Debounce> | ||
</div> | ||
) | ||
); | ||
} | ||
@@ -79,2 +81,5 @@ } | ||
[github-stars-img]: https://img.shields.io/github/stars/teneff/react-debounce.svg?logo=github&logoColor=fff | ||
[github-stars-url]: https://github.com/teneff/react-debounce/stargazers | ||
[github-stars-url]: https://github.com/teneff/react-debounce/stargazers | ||
[codesandbox-img]: https://codesandbox.io/static/img/play-codesandbox.svg | ||
[codesandbox-url]: https://codesandbox.io/s/927l985x94 |
240051
81