如何在React Native中onBlur时调用TextInput onEndEditing



在React Native中,如何在触发onBlur事件时调用TextInputonEndEditing回调?

我找到了解决方案。

有了这段代码,当onBlur事件触发时,我可以调用onEndEditing回调

<TextInput
ref={ input => { this.thisInput = input }}
clearButtonMode={"always"}
multiline = {false}
numberOfLines = {1}
maxLength = {16}
onEndEditing={ event => {
let value = (!!event.nativeEvent && !!event.nativeEvent.text ) ? event.nativeEvent.text : event;
// some code
}}
onBlur={ blurEvent => {
this.thisInput.props.onEndEditing( this.thisInput._lastNativeText );
}}
/>

相关内容

  • 没有找到相关文章

最新更新