Perform debounce in React.js

前端 未结 30 1950
礼貌的吻别
礼貌的吻别 2020-11-22 04:11

How do you perform debounce in React.js?

I want to debounce the handleOnChange.

I tried with debounce(this.handleOnChange, 200) but it doesn\'t

30条回答
  •  日久生厌
    2020-11-22 04:52

    you can use tlence tlence

    function log(server) {
      console.log('connecting to', server);
    }
    
    const debounceLog = debounce(log, 5000);
    // just run last call to 5s
    debounceLog('local');
    debounceLog('local');
    debounceLog('local');
    debounceLog('local');
    debounceLog('local');
    debounceLog('local');
    

提交回复
热议问题