Search code examples
javascriptreact-nativereact-native-textinput

Keep showing keyboard when press keyboards submit button


I want to keep showing keyboard. For example, when I press submit, the process takes place and the keyboard remains open.

<TextInput
        style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
        onChangeText={(text) => SetText(text)}
        onSubmitEditing={() => press(text)}
      />

Like sending messages in whatsapp. It's kind of the opposite of keyboard.dismiss().


Solution

  • TextInput component from react-native has a property specifically for that - blurOnSubmit:

    <TextInput blurOnSubmit={false} {...yourOtherProps} />
    

    You can find the documentation here: https://github.com/facebook/react-native-website/blob/master/docs/textinput.md#bluronsubmit