问题
How to trace changes in store from this component. In the external component Menu, I select the menu item and dispatch to store as parameter content. Depending on what I chose, I need to substitute the contents of the following component:
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);
来源:https://stackoverflow.com/questions/47363729/react-redux-listen-to-store-changes