在 TextInput React Native 中禁用返回键

Pra*_*hli 5 textinput react-native

我正在使用 React Native 的 TextInput。我想根据要求禁用返回键。有没有办法通过自定义代码禁用/启用返回键?我尝试使用 enableReturnKeyAutomatically 但它不起作用。

小智 0

是的,我们可以,通过使用 的onSubmitEditingprops TextInput。在这里发布示例:

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