如何从此组件跟踪商店中的更改。在外部组件Menu
中,我选择菜单项并将其分配为参数content
。根据我的选择,我需要替换以下组件的内容:
class WorkSpace extends Component {
constructor(props) {
super(props);
this.state = {
content: this.props.mainStore.content
}
}
render() {
return (
<div className = "workspace">
//some content
</div>
);
}
}
export default connect(
state => ({
mainStore: state
}),
dispatch =>({})
)(WorkSpace);