-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
const createThrottleProxy = (fn, rate) => {
let lastClick = Date.now() - rate
return new Proxy(fn, {
apply(target, context, args) {
if (Date.now() - lastClick >= rate) {
fn(args)
lastClick = Date.now()
}
},
})
}
clickMe = () => {
console.log('132423525')
}
<Button onClick={createThrottleProxy(this.clickMe, 3000)}>提交</Button>