communication child to parent react js
import React from 'react';
import Child from './Child'
export default class Parent extends React.Component {
constructor(props){
super(props);
this.state ={ text:''};
}
handleChangeInParent = (event) => {
this.setState({text:event.target.value})
}
render() {
return (
<>
<p>You have written: </p>
<p>{this.state.text}</p>
<Child handleChange={this.handleChangeInParent}/>
</>
)
}
}