Cnilton / react-native-floating-label-input

A customizable React Native TextInput with its placeholder always shown. Includes masks, global styles, character count, and a bunch else.
MIT License
293 stars 60 forks source link

Focus text fields while clicking next #96

Closed sritharIOS closed 3 years ago

sritharIOS commented 3 years ago

Hi Author,

Can you please guide me that how to implement the focus text field while clicking the next button?

Cnilton commented 3 years ago

Hi @sritharIOS, sure!

To achieve that you need to declare a ref and pass it to the input, like so:


import { useRef } from 'react';
import { View } from 'react-native';
import { FloatingLabelInput } from 'react-native-floating-label-input';

export const YourFunction () => {

  const inputRef1 = useRef(null);
  const inputRef2 = useRef(null);

  return (
    <View>

      <FloatingLabelInput
         // ...all your other props
         ref={inputRef1}
         onSubmitEditing={() => inputRef2?.current?.focus() }
       />

       <FloatingLabelInput
         // ...all your other props
         ref={inputRef2}
       />

    </View>
 )
}