-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
51 lines (47 loc) · 1.17 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { Component} from 'react';
import MainUI from './UI/MainUI';
import {connect} from 'react-redux';
import { changeInput, addTodo,deleteTodo } from './Redux/ActionCreators';
class App extends Component {
render() {
//UI组件
return (
<MainUI
input = {this.props.input}
inputOnChange = {this.props.inputOnChange}
addItem = {this.props.addItem}
todos = {this.props.todos}
deleteItem = {this.props.deleteItem}
addFav = {this.props.addFav}
starStatus = {this.props.starStatus}
/>
);
}
}
const mapStatetoProps = (state) =>{
return {
starStatus:state.starStatus,
input : state.input,
todos: state.todos
}
}
const mapDispatchToProps = (dispatch) =>{
return {
//input改变时
inputOnChange(e){
const action = changeInput(e.target.value);
dispatch(action)
},
//添加事项
addItem(){
const action = addTodo();
dispatch(action)
},
//删除事项
deleteItem(index){
const action = deleteTodo(index);
dispatch(action)
}
}
}
export default connect(mapStatetoProps,mapDispatchToProps)(App);