Home > OS >  React Native : Not able to switch to next TextInput on returnKeyType="next" using ref
React Native : Not able to switch to next TextInput on returnKeyType="next" using ref

Time:12-14

I am trying to move the focus from one TextInput to another on keyboard next press like in the below code in typescript

But it shows "Property 'focus' does not exist on type 'never'.ts(2339)" error

Is there any other method to do the same functionality

const emailRef = React.useRef()
const passwordRef = React.useRef()

<TextInput
     ref={emailRef }                             // Current TextInput Ref
     onSubmitEditing={()=>passwordRef .current?.focus()}  // Changing focus
     secureTextEntry={isSecured}
     placeholder={placeHolder}
     placeholderTextColor={GREY[400]}
     selectionColor={GREY[900]}
     style={styles.inputText}
     onChangeText={onChangeText}
     keyboardType={keyboardType}
     onEndEditing={onEndEditing}
     autoFocus={autoFocus}
     returnKeyType={returnKeyType}
/>

CodePudding user response:

you can try this

inputRef = React.createRef<TextInput>();
  • Related