Skip to content

Commit 09b437c

Browse files
authored
add useDebounce returning data better explanation
1 parent e84bac1 commit 09b437c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ const rootElement = document.getElementById('root');
241241
ReactDOM.render(<Input defaultValue="Hello world" />, rootElement);
242242
```
243243

244+
The same API is available for `useDebounce` calls:
245+
```js
246+
const [value, {cancel, isPending, flush}] = useDebounce(valueToDebounce);
247+
...
248+
cancel() // cancels pending debounce request
249+
isPending() // returns if there is a pending debouncing request
250+
flush() // immediately flushes pending request
251+
```
252+
253+
244254
#### Flush method
245255

246256
`useDebouncedCallback` has `flush` method. It allows to call the callback manually if it hasn't fired yet. This method is handy to use when the user takes an action that would cause the component to unmount, but you need to execute the callback.

0 commit comments

Comments
 (0)