Open mianmalife opened 5 years ago
import { createStore } from 'redux'; import { Provider } from 'react-redux; // 连接store const App = ( <Provider store={store}> <TodoList /> </Provider> } import { connet } from 'react-redux'; export default connet( mapStateToProps,mapDispathToProps )( TodoList ); // store state -> props-> this.props const mapStateToProps = (state) => { return { inputValue: state.inputValue } } // store.dispath ,props this.props.changeInputValue const mapDispathToProps = (dispath) => { return { changeInputValue(e) { console.log(e); const action = {}; dispath(action); } } } reducer--->return newState;