Reactjs 反应本机文本输入如何调节onBlur函数

Reactjs 反应本机文本输入如何调节onBlur函数,reactjs,react-native,Reactjs,React Native,在我的React Native项目中,我有以下代码: <TextInput onBlur={(e) => this.handleBlurCheck(e, ...otherParams)}/> this.handleBlurCheck(e,…otherParams)}/> 我想限制功能handleBlurCheck,但在React Native中,我不知道如何操作 另外,我需要事件参数。假设您的组件中有一个名为handleBlurCheck的函数,您可以创建一个新函数: th

在我的React Native项目中,我有以下代码:

<TextInput onBlur={(e) => this.handleBlurCheck(e, ...otherParams)}/>
this.handleBlurCheck(e,…otherParams)}/>
我想限制功能
handleBlurCheck
,但在React Native中,我不知道如何操作


另外,我需要
事件
参数。

假设您的组件中有一个名为
handleBlurCheck的函数,您可以创建一个新函数:

this.throttledHandleBlurCheck = _.throttle(this.handleBlurCheck, timeWindow)
然后,在渲染代码中:

<TextInput onBlur={(e) => this.throttledHandleBlurCheck(e,...otherParams) }/>
this.throttledHandleBlurCheck(e,…otherParams)}/>

throttle,你的意思是希望事件处理程序在给定的时间内只发生N次吗?在给定的时间内,只需触发1次就可以使用lodash,它有一个名为
debounce
的函数,完全符合你的要求。我知道,但在这里如何使用它创建一个新函数?像这样:throttledHandleBlurCheck(e,subTitle,identifier){this.throttledHandleBlurCheck=debounce(this.handleBlurCheck,this)}不,它不起作用不,我写的表单已经创建了这个函数。例如,您可以将其放入组件构造函数中。但是函数
throttledHandleBlurCheck
用于什么?空函数?我需要通过
把手检查
传递参数;如果没有lodash,我能实现它吗?当您使用
throttle
时,它会创建一个封装给定函数的函数。您提供给新函数的任何参数都将传递给原始函数。不客气。如果答案解决了您的问题,请将其标记为已接受。这将防止其他人试图回答相同的问题。