-
Notifications
You must be signed in to change notification settings - Fork 107
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
Cant seem to get Throttle working with onClick #47
Comments
It seems to be misuse. Description: In addition,
An example of available solutions: const ThrottledButton = ({ onClick, ...props }) => {
const debuoncedRef = React.useRef(null);
if (debouncedRef.current === null) { debouncedRef.current = throttle(1000, true, props.onClick); }
const handleOnClick = debouncedRef.current;
return <button onClick={handleOnClick} {...props}>{props.children}</button>
} |
Hi there,
Apologies, this may be down to me implementing the package incorrectly, but I dont seem to be able to get throttle to work with an onClick - if I rapidly click the button, the console log is fired multiple times. I have this set up as follows:
I have also tried this in the following configuration, which also doesnt seem to work:
As mentioned, if I rapidly click the buttons in either of these configurations, I see
FIRED
console logged multiple times.The text was updated successfully, but these errors were encountered: