React-native TextInput 如何限制 onBlur 函数
React-native TextInput how to throttle onBlur function
在我的 React Native 项目中,我有如下一段代码:
<TextInput onBlur={(e) => this.handleBlurCheck(e, ...otherParams)}/>
我想限制函数 handleBlurCheck
,但在 React Native 中,我不知道该怎么做。
此外,我需要 event
参数。
假设您的组件中有一个名为 handleBlurCheck
的函数,您可以创建一个新函数:
this.throttledHandleBlurCheck = _.throttle(this.handleBlurCheck, timeWindow)
然后,在您的渲染代码中:
<TextInput onBlur={(e) => this.throttledHandleBlurCheck(e,...otherParams) }/>
在我的 React Native 项目中,我有如下一段代码:
<TextInput onBlur={(e) => this.handleBlurCheck(e, ...otherParams)}/>
我想限制函数 handleBlurCheck
,但在 React Native 中,我不知道该怎么做。
此外,我需要 event
参数。
假设您的组件中有一个名为 handleBlurCheck
的函数,您可以创建一个新函数:
this.throttledHandleBlurCheck = _.throttle(this.handleBlurCheck, timeWindow)
然后,在您的渲染代码中:
<TextInput onBlur={(e) => this.throttledHandleBlurCheck(e,...otherParams) }/>