【发布时间】:2019-03-01 11:10:23
【问题描述】:
使用 lodash 的 debounce(),我试图等待 1.2 秒,然后在我的应用程序状态中设置搜索词。但是当我使用它时它似乎没有运行我的功能:
onChangeText(text) {
console.log('setting');
setSearching(true);
setSearchTerm(text);
}
render(){
return(
<TextInput style={s.input}
onChangeText={() => {
_.debounce(this.onChangeText, 1200);
/*
doing just...
this.onChangeText(text)
...works
*/
}}
/>
)
}
使用debounce 时,我的控制台日志中没有setting。有什么想法吗?
【问题讨论】:
标签: react-native lodash debouncing