update value parent component to child react native code example
Example: pass data from child component to parent component react native
class Parent extends React.Component {
state = { message: "" }
callbackFunction = (childData) => {
this.setState({message: childData})
},
render() {
return (
<div>
<Child1 parentCallback = {this.callbackFunction}/>
<p> {this.state.message} </p>
</div>
);
}
}
class Child1 extends React.Component{
sendData = () => {
this.props.parentCallback("Hey Popsie, How’s it going?");
},
render() {
}
};