1import React from 'react';
2
3import Child from './Child'
4
5export default class Parent extends React.Component {
6
7 constructor(props){
8
9 super(props);
10
11 this.state ={ text:''};
12
13 }
14
15 handleChangeInParent = (event) => {
16
17 this.setState({text:event.target.value})
18
19 }
20
21 render() {
22
23 return (
24
25 <>
26
27 <p>You have written: </p>
28
29 <p>{this.state.text}</p>
30
31 <Child handleChange={this.handleChangeInParent}/>
32
33 </>
34
35 )
36
37 }
38
39}