import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { Provider } from 'react-redux'
import store from './store'
ReactDOM.render(
, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
import React, { Component } from 'react'
import './App.css'
import ListItem from './DelItem'
import { inputChange,addTo, delItem, initList, getTodoList} from './actions'
import { connect } from 'react-redux'
class A extends Component {
constructor (props) {
super(props)
this.add = this.add.bind(this)
}
add () {
this.props.add (this.props.inputVal)
}
render () {
const { todos, inputVal } = this.props
return (
{
todos.map((todo,i) => (this.delItem(i)}> ))
}
)
}
}
const mapStateToProps = (state) => {
return {
todos: state.todos,
inputVal: state.inputVal
}
}
const mapDispatchToProps = (dispatch, ownProps) => {
return {
changeInputVal (e) {
const action = inputChange(e.target.value)
dispatch(action)
},
add (inputVal) {
const action = addTo(inputVal)
dispatch(action)
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(A)