component 間 互相存取
Component互相存取
openDrawer = () => {
this.drawer.openTheDrawer();
};
<Drawer onRef={ref => (this.drawer = ref)}>
.....
<button onClick={() => this.openDrawer()} />
</Drawer> componentDidMount() {
this.props.onRef(this)
}
openTheDrawer(){
....
};
render(){
<div>
......
{this.props.children}
</div>
}Passing child red to parent
Last updated