API of hooks are not documented
Closed this issue · 2 comments
vitonsky commented
When i read the readme, i can't understand the API of hooks in the library.
For example, when i see
import React, { useState } from 'react';
import { useDebounce } from 'use-debounce';
export default function Input() {
const [text, setText] = useState('Hello');
const [value] = useDebounce(text, 1000);
return (
<div>
<input
defaultValue={'Hello'}
onChange={(e) => {
setText(e.target.value);
}}
/>
<p>Actual value: {text}</p>
<p>Debounce value: {value}</p>
</div>
);
}
it seems useDebounce(text, 1000);
returns array with multiple entities. First is debounced value and something more that is not documented.
I propose to fix this bug in documentation with one of
- add entities signatures with explanation
- explain explicitly that
useDebounce
returns array with only one element (if it is yours logic)
devlopersabbir commented
Even I also suggest doing this...
xnimorz commented
Hello @vitonsky , @devlopersabbir
The returning value is accessible from the useDebounce typing, which is 100% covered with TS type system.
Additionally for convenience we added documentation here 09b437c