React-Redux。 聆听商店变化

问题描述 投票:0回答:0

如何从此组件跟踪商店中的更改。 在外部组件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);
reactjs redux react-redux
© www.soinside.com 2019 - 2024. All rights reserved.