Disable return key in TextInput React native

Viewed 481

I'm using React Native's TextInput. I want to disable return key as per the requirement. Is there any way to disable/enable return key by custom code? I tried with enablesReturnKeyAutomatically but it doesn't work.

1 Answers

Yes we can, by using the onSubmitEditing props for TextInput. Posting sample here:

<TextInput                   
  value={password}   
  returnKeyType="done"  
  onSubmitEditing={() => {
      if (password != '') {
          onLoginPressed();
      }    
  }}    
  placeholder="Password"    
  sub_place="PASSWORD"                     
  onChangeText={value => setPassword(value)}                     
  blurOnSubmit={false}    
  ref={passwordFocus}   
/>
Related