-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat: new hook useThrottleCallback
#118
Conversation
Codecov Report
@@ Coverage Diff @@
## master #118 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 31 32 +1
Lines 498 524 +26
Branches 91 96 +5
=========================================
+ Hits 498 524 +26
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The demo seems to be broken, so I think the throttle implementation might be wrong or I might be misunderstanding using throttle in this case.
It seems that this throttle callback drops the final run on the floor. See the example below - there is more text in the box than the displayed value, even through 500ms has passed.
Ah🤔 interesting, I'll watch other implementations, but this seems to be proper behavior, according to what is throttling. |
Just checked, |
36ed660
to
8f1cc0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better!
# [2.2.0](v2.1.0...v2.2.0) (2021-06-15) ### Features * new hook useThrottleCallback ([#118](#118)) ([afec60b](afec60b))
🎉 This PR is included in version 2.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What new hook does?
Makes passed function throttled, otherwise acts like
useCallback
.Checklist
react-use
#33