import React,{Component} from "react"
class Son extends Component{
constructor(props){
super(props);
}
render(){
const {isShow} =this.props;
return(
<div onClick={isShow}>
我是子组件
</div>
)
}
}
export default class sonCallfather extends Component{
constructor(props){
super(props);
this.state={
isshow:true
}
}
hideSon =() =>{
this.setState({
isshow:false
});
}
showSon =() =>{
this.setState({
isshow:true
});
}
render(){
const {isshow} =this.state;
return(
<div>
子组件在父组件里面展示
{isshow ? <Son isShow={this.hideSon}/> :
<div onClick={this.showSon}>
我影藏了,点我就出来
</div>}
</div>
)
}
}