store.getState or mapStateToProps in Component
问题 I have a question that what is the difference between use getState from store directly or use mapStateToProps. Please look at me example below import React, { Component } from 'react' import store from '../store' import { connect } from 'react-redux'; class Test extends Component { constructor(props) { super(props); } render() { return ( <p> <h1>{this.props.count}</h1> <h2>{store.getState().reducer1.count}</h2> </p> ) } } const mapStateToProps = (state) => ({ count: state.reducer1.count }); /