Skip to content

Conversation

@abumalick
Copy link

Added section on using the debounced setter with example.

Currently this is not documented and AI is complaining when using this because when looking at the documentation it does not see it anywhere

Added section on using the debounced setter with example.
Copy link
Owner

@xnimorz xnimorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's needed. If you want to add information of a setter inside a tuple, I suggest adding it right after the example of usage.

Comment on lines +101 to +113
import React from 'react';
import { useDebounce } from 'use-debounce';

export default function Input() {
const [state, setState] = useDebounce('', 300);

return (
<div>
<input onChange={(e) => setState(e.target.value)} />
<p>Debounced value: {state}</p>
</div>
);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same example exist right above the added section.
I don't think repetition is needed here


### Using the debounced setter

In addition to getting the debounced value, you can destructure a second element which is a debounced setter function. This allows you to use `useDebounce` without needing a separate state variable for the input value:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not "in addition". It's main feature, explained above.
If you want to add additional information, let's put simple inside this section https://github.com/xnimorz/use-debounce/blob/master/README.md#simple-values-debouncing
useDebounce returns a tuple with 2 arguments: debounced value and setter.

}
```

This is particularly useful when you don't need to track the immediate input value and only care about the debounced result. The debounced setter also provides additional methods like `cancel`, `isPending`, and `flush` for advanced control.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's covered below.

@xnimorz xnimorz added the invalid This doesn't seem right label Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants