useDebounceHooks
React custom hook
- useDebounce
- useDebounceProps
- useDebounceCallback
install
$ npm install use-debounce-hooks
useDebounce
A useDebounce
is hook of update state
after a waiting time.
This hook can use like a useState
.
;; const WaitTime = 300; { const value setVal cancel = ; return <div> <input onChange= /> /* The value is updated when the timer expires after the last onChange event. */ <p>Debounce Value: value</p> <button onClick= >CANCEL TO UPDATE</button> </div> ;}
useDebounceProps
A useDevounceProps
is hook of debounce update a state
by props
.
Debounce timer is start after props
changed.
;; const WaitTime = 300; { const value cancel = ; return <div> <p>Debounce Value: value</p> <button onClick= >CANCEL TO UPDATE</button> </div> ;} { const value setVal = ; const onIncrement = { ; }; return <div> <button onClick=onIncrement>value</button> <Component value=value /> </div> ;}
useDebounceCallback
A useDebounceCallback
is hook of debounce update a state
via the callback function.
After debounce timer expired call a callback and set it's return value to the state
.
;; const WaitTime = 300;const Tax = 01; { const tax = 1 + Tax; const addTax = ; const value setVal cancel = ; return <div> <input onChange= /> <p>Debounce Value: value</p> <button onClick= >CANCEL TO UPDATE</button> </div> ;}