JSFiddle - React, Tailwind, and code Playground

JavaScript

function smartInterval(cb, interval) {
    var executed, timeout;
    return function() {                    
        var args = arguments;
        if(!executed) executed = +new Date;
        setTimeout(function execute(){
            if(+new Date-executed > interval) {
                cb.apply(this, args);
                executed = +new Date;
                timeout = null;
            } else if(!timeout){
                timeout = setTimeout(execute, interval)
            }
        }, 10); 
    }
}

//mousemove будет срабатывать раз в 2 секунды
var d = +new Date;
window.onmousemove = smartInterval(function(e) {console.log(e.clientX,+new Date-d)}, 2000)