We need to have onBlur and onChange events listeners for the select for the "block user" as it advised by es-lint. But if we simply add onBlur event listener it will cause infinite loop of blur -> confirm pop-up -> cancel -> blur -> confirm pop-up... So we have to debounce the events to process them only one time.
9 lines
218 B
JavaScript
9 lines
218 B
JavaScript
export default function debounce(func, wait) {
|
|
let timeout;
|
|
return function() {
|
|
const laterCall = () => func.apply(this, arguments);
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(laterCall, wait);
|
|
};
|
|
}
|