-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
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:
//throttled-button.js
const ThrottledButton = (props) => {
const handleOnClick = () => throttle(1000, true, props.onClick)
return <button onClick={handleOnClick} {...props}>{props.children}</button>
}
// logout.js
const handleLogout = () => {
console.log("FIRED")
logoutUser()
}
<ThrottledButton onClick={handleLogout} type='button'>Logout</ThrottledButton>I have also tried this in the following configuration, which also doesnt seem to work:
// logout.js
const handleLogout = throttle(1000, true, () => {
console.log("FIRED")
logoutUser()
})
<button onClick={handleLogout} type='button'>Logout</button>As mentioned, if I rapidly click the buttons in either of these configurations, I see FIRED console logged multiple times.
Metadata
Metadata
Assignees
Labels
No labels