React-Redux. Listen to store changes

社会主义新天地 提交于 2020-01-06 05:51:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!