Answers for "react native textinput lost focus after charter type"

0

react native textinput lost focus after charter type

Your TextInput components are being recreated and re-rendered each time you type something.

there are two main. solution i gusess:

use  onBlur={}

and  user autoFocus={true}

=======================================================================
or other solutions is blow you can use TextInput like this
const handleChange = (event) => {
        const {name, type, text} = event;
        setValues({...values, [name]: text})
    }


const MyTextInput = ({ valueVar, name, type, onChange }) => {
   return (
        <TextInput
            style={styles.textInputStyle}
            value={valueVar}
            onChangeText={text => onChange({ name, type, text })}
        />
   );
};


in return (

<MyTextInput
  name="email"
  type="text"
  valueVar={values.email}
onChange={handleChange}
/>
)
Posted by: Guest on May-20-2021

Code answers related to "react native textinput lost focus after charter type"

Code answers related to "Javascript"

Browse Popular Code Answers by Language