React Native:How to trigger TextInput instance blur in a method?

Viewed 4025

I click a button on the navigator, the current screen's one TextInput's is focus. I need to set the TextInput's instance blur to trigger the textChange function to do something.

In my case, the cursor of TextInput is blinking all the time.

refs.username.blur() does not work.

enter image description here

My code :

class UploadRecordII extends Component{
  static navigationOptions = ({ navigation, screenProps }) => ({
    headerRight: (<Button containerStyle={{marginRight: 12,}} onPress={ UploadRecordII.onSubmit}>
                  <Text style={{color: 'white',fontSize: 18,}}>next</Text>
                </Button>),
  });
.....


   static onSubmit() {
    let that = UploadRecordII.instance;
     debugger;
     that.refs.username.blur();
     debugger;
    that.props.commitCreateRecordUpdate(that.refs.username._lastNativeText,that.imageList)
    that.props.navigation.navigate('Record3');
  }



......  in render(){
....

<TextInput ref = 'username' placeholder='' editable = {true} maxLength = {500}
                  keyboardType='default' multiline={true}
                  style={styles.input} underlineColorAndroid='rgba(0,0,0,0)'
                           onBlur={  ()=> this.textChange()}
                  clearButtonMode='always' placeholderTextColor='#D6D0D8'></TextInput>



...
}
1 Answers
Related