mianmalife / notebook

记录一下
2 stars 0 forks source link

react-redux使用 #5

Open mianmalife opened 5 years ago

mianmalife commented 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;