2016-11-25 61 views

回答

3

您可以使用lodash的防抖動()函數(基本上是小window.setTimeout招扼殺千呼萬喚):

import _ from 'lodash'; 

... 

doSearch(text) { 
    // Your normal handler here 
} 

... 

// Delay autocomplete until 500 ms after use stops typing 
<AutoComplete 
    onUpdateInput={_.debounce((value) => doSearch(value), 500)} 
    ... 
/>