1. Especially troublesome when using public state. 2. Subscribe to the way to re-render the component after the status update

1. Create conditions:

Import {provider} from 'react-redux'; import {provider} from 'react-redux'; import {provider} from 'react-redux'; import store from './store/index' render() { <provider sotre={store}> <Vote /> </provider> }Copy the code

2. Use

// Connect is a high-order component that passes state and ACTION from the store as properties to the bound component. // The result is a proxy component that is used for rendering, and does not need to subscribe to the function after the state update. Import {connect} from 'react-redux' import Vote from the REDUX container event pool import {connect} from 'react-redux' import Vote from './Vote' //function mapStateToProps(state) {// return state; //return an object whose status information is attached to the component properties as properties. State.vote //} //} // // function mapDispatchToProps(dispacth){// // dispacth === store. Dispacth // return {// //this.props. ChangeSup () {// dispacth(action.vote.changesupnum) //} // //connect(mapStateToProps, mapDispatchToProps)(Vote) //connect(mapStateToProps, action.vote)(Vote) connect(state=>({... State.vote}),action.vote)(vote) // The function with the same name is called when distributedCopy the code