Answer the question
In order to leave comments, you need to log in
Why is the TextInput in the component cleared when editing the TextInput in the parent component?
For example, there is a component
function TestComponent()
{
const [testValue, setTestValue] = useState('');
return <TextInput
value={testValue}
onChangeText={(text) => setTestValue(text)}
style={styles.input}
placeholder="Текст"
maxLength={50}
/>
}
<TextInput
value={someValue}
onChangeText={(text) => setSomeValue(text)}
style={styles.input}
placeholder="Текст"
maxLength={50}
/>
<TestComponent/>
Answer the question
In order to leave comments, you need to log in
1 store the value of the child component in the parent
2 store the value for example in redux
3 try using shouldComponentUpdate
4 raise the imput field in the parent component
5 you can also look towards React.memo and React.PureComponent
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question