Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 取消Bouncing搜索输入onChangeText()_React Native_Lodash_Debouncing - Fatal编程技术网

React native 取消Bouncing搜索输入onChangeText()

React native 取消Bouncing搜索输入onChangeText(),react-native,lodash,debouncing,React Native,Lodash,Debouncing,使用lodash的debounce()。但当我使用它时,它似乎没有运行我的函数: onChangeText(text) { console.log('setting'); setSearching(true); setSearchTerm(text); } render(){ return( <TextInput style={s.input} onChangeText={() => {

使用lodash的
debounce()。但当我使用它时,它似乎没有运行我的函数:

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
                */
            }}
        />
    )
}
onChangeText(文本){
console.log('setting');
设置搜索(真);
设置搜索项(文本);
}
render(){
返回(
{
_.debounce(此.onChangeText,1200);
/*
正在做的只是。。。
此.onChangeText(文本)
作品
*/
}}
/>
)
}

使用
debounce
时,我的控制台日志中没有
设置。有什么想法吗?

现在,您正在为处理程序的每次调用创建一个新的
debounce
实例

理想情况下,您应该将整个处理程序包装在
debounce
中,因为debounce会创建一个
debounced
函数来延迟调用
func


现在,在处理程序的每次调用中,您都要创建一个新的
debounce
实例

理想情况下,您应该将整个处理程序包装在
debounce
中,因为debounce会创建一个
debounced
函数来延迟调用
func


这是可行的,但如何调用
setsearch(true)在去盎司之前?不确定,但您可能需要在函数内部使用
debounce
,仅用于
setSearchTerm
函数
。\uBounce(()=>searchTerm(text),1200)
这是有效的,但我如何调用
setSearching(true)在解盎司之前?不确定,但您可能需要在函数内部使用
debounce
,仅用于
setSearchTerm
函数
。\debounce(()=>searchTerm(text),1200)
onChangeText={_.debounce(this.onChangeText, 1200)}