-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# useDebounceEffect | ||
|
||
Debounce an effect. | ||
|
||
```ts | ||
useDebounceEffect( | ||
() => { | ||
doSomething(); | ||
}, | ||
[], | ||
{ timeout: 1000 }, | ||
); | ||
``` | ||
|
||
## Parameters | ||
|
||
### effect | ||
|
||
- Type: `EffectCallback` | ||
|
||
The effect to be debounced. | ||
|
||
### deps | ||
|
||
- Type: `DependencyList` | ||
- Default: `undefined` | ||
|
||
The dependencies of the effect, just like in `useEffect`. | ||
|
||
### options | ||
|
||
- Type: `UseDebounceEffectOptions` | ||
- Default: `{}` | ||
|
||
The options to configure the hook. | ||
|
||
## Options | ||
|
||
### timeout | ||
|
||
- Type: `number` | ||
- Default: 500 | ||
|
||
The time in milliseconds between the last call of the effect and the actual execution. | ||
|
||
Changes of this value will clear the current timer (with the old `timeout` value) and start a new one (with the new `timeout` value). | ||
|
||
### onMount | ||
|
||
- Type: `boolean` | ||
- Default: `false` | ||
|
||
Whether to immediately call the effect and trigger the debouncing mechanism when the hook is mounted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters