Skip to content

Commit 2117669

Browse files
committed
docs: update README.md
1 parent e85379e commit 2117669

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,65 @@ Parâmetros
7878
- **initialValue**: O valor inicial do estado.
7979
- **delay**: O tempo em milissegundos para o throttling.
8080

81+
# Funções Disponíveis
82+
83+
## debounce
84+
85+
Uma função que gerencia outra função com debounce, permitindo que as atualizações sejam agrupadas depois de um período de inatividade.
86+
87+
```js
88+
import { debounce } from "react-timing-hooks"
89+
90+
function Example() {
91+
const [debouncedValue, setDebouncedValue] = useState("")
92+
93+
const debouncedFunction = debounce((newValue: string) => {
94+
setDebouncedValue(newValue)
95+
}, 1000)
96+
97+
const handleChange = e => {
98+
debouncedFunction(e.target.value)
99+
}
100+
101+
return <input type="text" onChange={handleChange} />
102+
}
103+
```
104+
105+
Parâmetros
106+
107+
- **function**: Função a ser debounced.
108+
- **delay**: O tempo em milissegundos para o debounce.
109+
110+
## throttle
111+
112+
Uma função que gerencia outra função com throttling, permitindo que as atualizações sejam limitadas a um intervalo de tempo especificado.
113+
114+
```js
115+
import { throttle } from "react-timing-hooks"
116+
117+
function Example() {
118+
const [throttledValue, setThrottledValue] = useState("")
119+
120+
const throttledFunction = React.useCallback(
121+
throttle((newValue: string) => {
122+
setThrottledValue(newValue)
123+
}, 2000),
124+
[],
125+
)
126+
127+
const handleChange = e => {
128+
throttledFunction(e.target.value)
129+
}
130+
131+
return <input type="text" onChange={handleChange} />
132+
}
133+
```
134+
135+
Parâmetros
136+
137+
- **function**: Função a ser throttled.
138+
- **delay**: O tempo em milissegundos para o throttling.
139+
81140
## Exemplos
82141

83142
Veja exemplos na pasta _example_.

0 commit comments

Comments
 (0)