react-convenience
Version:
React Utilities.
42 lines (23 loc) • 829 B
Markdown
React Utilities.
Run `yarn add react-convenience`
It delays execution of function, takes 2 argument first is callback and second is delay time.
```
import { debounceEvent } from 'react-convenience';
import { TextArea } from '...';
const handlerOnChange = e => console.log(e);
const debouncedHandler = debounceEvent(handlerOnChange, 500);
<TextArea onChange={debouncedHandler} />
```
HOC to help debounce handler onChange.
```
import { withOnChangeDebounce } from 'react-convenience';
import { TextArea } from '...';
const TextAreaWithDebounce = withOnChangeDebounce(500)(TextArea);
const handlerOnChange = e => console.log(e);
<TextAreaWithDebounce onChange={handlerOnChange} />
```