Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"leading: true" not working for v7 #124

Closed
mntnoe opened this issue Dec 14, 2021 · 8 comments
Closed

"leading: true" not working for v7 #124

mntnoe opened this issue Dec 14, 2021 · 8 comments
Labels
good first issue Good for newcomers

Comments

@mntnoe
Copy link

mntnoe commented Dec 14, 2021

Describe the bug
For the versions 7.0.0 and 7.0.1, setting { leading: true } does not trigger an immediate change in useDebounce. It works in 6.0.1 and below.

To Reproduce

  • The sandbox example linked to in the readme file (https://codesandbox.io/s/rr40wnropq) uses [email protected]. Add the option { leading: true } and observe that the debounced value is updated immedately for the first change.
  • Change the version number to 7.0.0 or 7.0.1, and observe that the behavior is now as if { leading: true } is not given.

Expected behavior
Setting { leading: true } should trigger immediately for the first change, and subsequently trigger immediately on changes after the wait timeout has expired.

use-debounce version:
7.0.0 and 7.0.1

@xnimorz
Copy link
Owner

xnimorz commented Dec 21, 2021

Hey, thank you for reporting the issue.
You're welcome to open the PR to fix it!

@xnimorz xnimorz added the good first issue Good for newcomers label Feb 12, 2022
@xnimorz
Copy link
Owner

xnimorz commented Feb 12, 2022

Labelling it as a good for new contributors, who are looking for possibilities to start with open source

@xnimorz
Copy link
Owner

xnimorz commented May 1, 2022

Hey @mntnoe
I've published v8.0.0 of the library.

Now it works with leading: true correctly, here is the demo:

https://codesandbox.io/s/cache-example-with-areas-and-leading-param-119r3i

If you get any issues during the update from 7.x.x => 8.x.x here is a guidance: https://github.com/xnimorz/use-debounce/blob/master/CHANGELOG.md#800

@xnimorz
Copy link
Owner

xnimorz commented May 1, 2022

I'm closing this issue as it should be resolved for now. Please, feel free to re-open it if you still get any issues with it

@xnimorz xnimorz closed this as completed May 1, 2022
@mntnoe
Copy link
Author

mntnoe commented May 2, 2022

Thank you for looking into this. When using { leading: true }, we get some strange behavior in our code with v8.0.0, where the new value is used initially, but then reverted:

VALUE  DEBOUNCED
a      a
b      a
b      b
bb     a
bbb    a
bbb    bbb

I'll try to investigate what happens when I get time.

@xnimorz xnimorz reopened this May 2, 2022
@xnimorz
Copy link
Owner

xnimorz commented May 2, 2022

@mntnoe interesting, thanks, I'll try to reproduce it too.

@xnimorz
Copy link
Owner

xnimorz commented Aug 28, 2022

I cannot repro it now. If you have an example, please share it. I'll close the issue for now

@xnimorz xnimorz closed this as completed Aug 28, 2022
@franzwarning
Copy link

I see this as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants