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

useDebouncedCallback: add a flush method to returned callback #7272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scamden
Copy link

@scamden scamden commented Dec 16, 2024

As well as give an option to simply flush on unmount, which is desirable when the callback does persisting of values (but not when it's just updating state obviously)

@scamden scamden force-pushed the patch-1 branch 2 times, most recently from 22e1e48 to 2ca6650 Compare December 19, 2024 17:54
@scamden
Copy link
Author

scamden commented Dec 19, 2024

Added tests, I think this is in a good state for review. Not sure who to at-ref here..

…d callback as well as give an option to simply flush on unmount
});


it('does not call after unmount if timer lapsed', () => {
Copy link
Author

Choose a reason for hiding this comment

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

this adds a test for the clearTimeout functionality in the useEffect, previously untested, not strictly related to this change :)

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

Successfully merging this pull request may close these issues.

1 participant