connect
顾名思义起到了链接的作用。store传递到子组件需要通过connect链接来建立prop和state、prop和dispatch的对应关系。它会统一的从context中取出store, 然后store中的数据都是通过mapStateToProps "传"到props,你就可以拿来显示啦;你修改store的操作,也通过mapDispatchToProps "传" 到props,你就可以修改数据。

https://segmentfault.com/q/1010000016267081

 

const mapDispatchToProps = (dispatch) => {
  return {
    onSwitchColor: (color) => {
      dispatch({ type: 'CHANGE_COLOR', themeColor: color })
    }
  }
}

  

https://www.love85g.com/?p=1595