react native textinput lost focus after charter type

Solutions on MaxInterview for react native textinput lost focus after charter type by the best coders in the world

showing results for - "react native textinput lost focus after charter type"
Mara
02 May 2019
1Your TextInput components are being recreated and re-rendered each time you type something.
2
3there are two main. solution i gusess:
4
5use  onBlur={}
6
7and  user autoFocus={true}
8
9=======================================================================
10or other solutions is blow you can use TextInput like this
11const handleChange = (event) => {
12        const {name, type, text} = event;
13        setValues({...values, [name]: text})
14    }
15
16
17const MyTextInput = ({ valueVar, name, type, onChange }) => {
18   return (
19        <TextInput
20            style={styles.textInputStyle}
21            value={valueVar}
22            onChangeText={text => onChange({ name, type, text })}
23        />
24   );
25};
26
27
28in return (
29
30<MyTextInput
31  name="email"
32  type="text"
33  valueVar={values.email}
34onChange={handleChange}
35/>
36)
37
38