Answer the question
In order to leave comments, you need to log in
How to change the State of a parent from a child element?
In parent
getlogin = (text) => {
this.setState({ login: text })
}
state = {
component: <Addprofile getLogin={this.getLogin} />,
login: ''
}
<TextInput style = {styles.input}
underlineColorAndroid = "transparent"
placeholder = "Логин инстаграм"
placeholderTextColor = "#9a73ef"
autoCapitalize = "none"
onChangeText = {props.getLogin(text)}
/>
Answer the question
In order to leave comments, you need to log in
1. Fix handler name:
getLogin = (text) => {
this.setState({ login: text })
};
<TextInput style = {styles.input}
/* ... */
onChangeText = {this.props.getLogin}
/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question