-
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.
Add documentation for useDebounce hook
- Loading branch information
Showing
3 changed files
with
148 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
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,72 @@ | ||
--- | ||
title: useDebounce | ||
description: Returns a debounced value of the provided value. | ||
--- | ||
|
||
## Installation | ||
|
||
Install the custom hook from your command line. | ||
|
||
<Snippet pkg text='@raddix/use-debounce' /> | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { useState } from 'react'; | ||
import { useDebounce } from 'ahooks'; | ||
|
||
export default function App() { | ||
const [value, setValue] = useState<string>(); | ||
const debouncedValue = useDebounce(value, { wait: 500 }); | ||
|
||
return ( | ||
<div> | ||
<input | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
placeholder="Typed value" | ||
/> | ||
<p>DebouncedValue: {debouncedValue}</p> | ||
</div> | ||
); | ||
}; | ||
``` | ||
|
||
## API | ||
|
||
### Parameters | ||
|
||
<ApiTable | ||
head={{ | ||
name: 'Parameters' | ||
}} | ||
data={[ | ||
{ | ||
name: 'value', | ||
description: 'The value you want to bounce.', | ||
required: 'Yes', | ||
type: 'any' | ||
}, | ||
{ | ||
name: 'delay', | ||
description: 'The delay time in milliseconds.', | ||
required: 'No', | ||
type: 'number' | ||
} | ||
]} | ||
/> | ||
|
||
### Returns | ||
|
||
<ApiTable | ||
head={{ | ||
name: 'Returns' | ||
}} | ||
data={[ | ||
{ | ||
name: 'debouncedValue', | ||
type: 'any', | ||
description: 'The debounce value. After the delay time has elapsed without the value changing, it will be updated to the most recent value.', | ||
} | ||
]} | ||
/> |
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,72 @@ | ||
--- | ||
title: useDebounce | ||
description: Devuelve un valor sin rebotes del valor proporcionado. | ||
--- | ||
|
||
## Instalación | ||
|
||
Instala el custom hook desde su linea de comando. | ||
|
||
<Snippet pkg text='@raddix/use-debounce' /> | ||
|
||
## Uso | ||
|
||
```tsx | ||
import { useState } from 'react'; | ||
import { useDebounce } from 'ahooks'; | ||
|
||
export default function App() { | ||
const [value, setValue] = useState<string>(); | ||
const debouncedValue = useDebounce(value, { wait: 500 }); | ||
|
||
return ( | ||
<div> | ||
<input | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
placeholder="Typed value" | ||
/> | ||
<p>DebouncedValue: {debouncedValue}</p> | ||
</div> | ||
); | ||
}; | ||
``` | ||
|
||
## API | ||
|
||
### Parámetros | ||
|
||
<ApiTable | ||
head={{ | ||
name: 'Parámetros' | ||
}} | ||
data={[ | ||
{ | ||
name: 'value', | ||
description: 'El valor que desea rebotar.', | ||
required: 'Si', | ||
type: 'any' | ||
}, | ||
{ | ||
name: 'delay', | ||
description: 'El tiempo de retardo en milisegundos.', | ||
required: 'No', | ||
type: 'number' | ||
} | ||
]} | ||
/> | ||
|
||
### Devuelve | ||
|
||
<ApiTable | ||
head={{ | ||
name: 'Devuelve' | ||
}} | ||
data={[ | ||
{ | ||
name: 'debouncedValue', | ||
type: 'any', | ||
description: 'El valor sin rebote. Una vez transcurrido el tiempo de retardo sin que el valor cambie, este se actualizará al valor más reciente.', | ||
} | ||
]} | ||
/> |