class Father extends Component {
construtor(props){
super
(props);
this
.state={
name:
'Peter'
,
age:
'26'
}
}
onChangeState(stateName){
this
.setState(stateName)
}
render(){
<p>姓名:{
this
.state.name}</p>
<p>年齡:{
this
.state.age}</p>
<Child onClicked={
this
.onChangeState.bind(
this
)}/>
}
}
class Child extends Component {
render(){
<Button onClicked={()=>
this
.props.onClicked({name:
'John'
})}/>
}
}