在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 );
}}
/>