import React from "react"; import { connect } from "react-redux"; const TodoList = (props) => { let { inputValue, inputChange, addItem, list, del } = props; return (
); }; const mapStateToProps = (state) => { return { inputValue: state.inputValue, list: state.list, // name:state.nameValue }; }; const dispatchTpProps = (dispatch) => { return { inputChange(e) { let action = { type: "inputChange", value: e.target.value, }; dispatch(action); }, addItem() { let action = { type: "addItem", }; dispatch(action); }, del(index) { let action = { type: "del", index, }; dispatch(action); }, }; }; export default connect(mapStateToProps, dispatchTpProps)(TodoList);