);
@@ -216,7 +227,10 @@ function Input({ defaultValue }) {
// you should use `e => debounced(e.target.value)` as react works with synthetic events
return (
@@ -252,7 +266,12 @@ function InputWhichFetchesSomeData({ defaultValue, asyncFetchData }) {
[debounced]
);
- return debounced(e.target.value)} />;
+ return (
+ debounced(e.target.value)}
+ />
+ );
}
```
@@ -264,7 +283,10 @@ function InputWhichFetchesSomeData({ defaultValue, asyncFetchData }) {
import React, { useCallback } from 'react';
function Component({ text }) {
- const debounced = useDebouncedCallback(useCallback(() => {}, []), 500);
+ const debounced = useDebouncedCallback(
+ useCallback(() => {}, []),
+ 500
+ );
expect(debounced.isPending()).toBeFalsy();
debounced();
@@ -316,7 +338,7 @@ You can provide additional options as a third argument to both `useDebounce` and
| maxWait | - | Describes the maximum time func is allowed to be delayed before it's invoked | https://github.com/xnimorz/use-debounce#cancel-maxwait-and-memoization |
| leading | - | This param will execute the function once immediately when called. Subsequent calls will be debounced until the timeout expires. | https://github.com/xnimorz/use-debounce#leading-calls |
| trailing | true | This param executes the function after timeout. | https://github.com/xnimorz/use-debounce#leading-calls |
-| equalityFn | (prev, next) => prev === next | [useDebounce ONLY] Comparator function which shows if timeout should be started | |
+| equalityFn | (prev, next) => prev === next | [useDebounce ONLY] Comparator function which shows if timeout should be started | |
## useThrottledCallback