Skip to content
New issue

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

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

Already on GitHub? # to your account

Setting leading: true after initialization #194

Open
make-github-pseudonymous-again opened this issue Feb 23, 2025 · 0 comments
Open

Setting leading: true after initialization #194

make-github-pseudonymous-again opened this issue Feb 23, 2025 · 0 comments

Comments

@make-github-pseudonymous-again

I'd like to use

const [debouncedValue] = useDebounce(value, {leading});

with leading being a dynamic value. The first update correctly fires immediately when switching to leading: true dynamically. However, it seems isPending is not reset.

I currently work this around with the following:

const [debouncedValue, {flush}] = useDebounce(value);
useEffect(() => {
  if (leading) flush();
}, [leading, flush]);

Would it make sense to properly handle dynamic options changes? Maybe this would not have the consequences I expect from the workaround.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant