Skip to content

Setting leading: true after initialization #194

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

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.

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

No branches or pull requests

1 participant