子组件:
componentDidMount() {
this.props.onRef(this);
}
closeTree = () => {
this.setState({
isShows: false
});
};
父组件:
jsx文件里:
onRefTree = ref => {
// this.childTree = ref;
this.props.dispatch({
type: 'updateState',
payload: {
childTree: ref
}
});
};
<Tree onRef={this.onRefTree}>
model文件里:调用子组件里closeTree方法
childTree.closeTree();