Reputation: 111
I have one text input in my child component and I want to get the text input data to my parent screen. I want to pass the data to one component to another component.
Upvotes: 0
Views: 407
Reputation: 12195
You have 2 components parent and child suppose , then it would be like
In render of Parent , basically you are passing a callback function to child
textChange = (value) => {
this.setState({newText:value});
}
render(){
return(
<Child onTextInput={this.textChange} />
)
}
and in child's render:
render(){
return(
<TextInput onChangeText={e => this.props.onTextInput(e)}
)
}
Hope it helps.
Upvotes: 1