import React,{Component}from'react'import{TodoHead,TodoInput,TodoList}from'./component'import{connect}from'react-redux'classAPPextendsComponent{constructor(){super();this.state={}}render(){return(<div><TodoHead {...this.props}/><TodoInput {...this.props} myadd={this.props.addItem}/><TodoList {...this.props} changeBox={this.props.changeBox}/></div>)}}constmapState= state => state
constmapAction= dispatch=>{return{addItem(title){dispatch({
type:'ADD_ITEM',
title
})},changeBox(id){dispatch({
type:"CHECK_BOX",
id
})}}}exportdefaultconnect(mapState,mapAction)(APP)
import{ADD_ITEM,CHECK_BOX,GET_TODO}from'../types'import axios from'../../API'exportconstaddItem=(title)=>{return{
type:ADD_ITEM,
title
}}exportconstchangeBox=(id)=>{return{
type:CHECK_BOX,
id
}}exportconstgetTodosAction=()=>{return{
type:GET_TODO}}exportconstgetTodos=()=>async dispatch=>{const res =await axios.get('/todos')dispatch(getTodosAction(res.data))
console.log(res)}