androidreact-nativemobile

React Native keyboard closes after focusing to next field from next key


i have use TexInputs inside A ScrollView and when i click next it goes to next text input field but closes the keyboard.here is the code i have used

 <View>
     <TextInput
       maxlength={20}
       autoFocus={true}
       returnKeyType="next"
       onFocus={() => this.setState({ isNameFocused: true })}
        onBlur={() => {this.props.user_auth_info.sign_up_info.FirstName===""? 
        this.setState({firstTimeName:true}):null}}
        style={{ marginLeft: 5 }}
        onChangeText={(text) => {this.handleFirstName(text)}}
        value={ this.props.user_auth_info.sign_up_info.FirstName}
        placeholder="  First name"
        placeholderTextColor={"grey"}
        onSubmitEditing={() => { {this.firstName.focus()}}
        blureOnSubmit={false}
                            />
    </View>

I have used

keyboardShouldPersistTaps="always"

but it did not worked for me


Solution

  • i have used setState in TextInput and so when i focus from keybord next to next field keybord get closed because the setState function is running.so i added setTimeout for setting state and that solves the keybord closing when focused