Open nklhtv opened 1 week ago
Describe the bug Value is not debounced when leading and trailing are both set to true
leading
trailing
Used to work in 10.0.1
To Reproduce
import React, { useState } from "react"; import ReactDOM from "react-dom"; import { useDebounce } from "use-debounce"; function Input({ defaultValue }) { const [value, setValue] = useState(defaultValue); const [debouncedValue] = useDebounce(value, 5_000, { leading: true, trailing: true, }); return ( <div> <input defaultValue={defaultValue} onChange={(e) => setValue(e.target.value)} /> <p>Value: {value}</p> <p>Debounced value: {debouncedValue}</p> </div> ); } const rootElement = document.getElementById("root"); ReactDOM.render(<Input defaultValue="Hello world" />, rootElement);
Expected behavior
1234
1
What actually happens is that debouncedValue is updated on each keystroke.
use-debounce version: 10.0.3
Hey @nklhtv ,
Thanks for submitting the request. I plan to land proper fix for isPending status upcoming week, which should fix that version. In the meantime, please, use 10.0.1
Describe the bug Value is not debounced when
leading
andtrailing
are both set to trueUsed to work in 10.0.1
To Reproduce
Expected behavior
1234
with 4 separate keystrokes in less than 5 seconds1
instantly1234
after 5 secondsWhat actually happens is that debouncedValue is updated on each keystroke.
use-debounce version: 10.0.3