-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.js
49 lines (40 loc) · 1003 Bytes
/
Home.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
/**
* Created by xingxiao05 on 17/5/9.
*/
import React from 'react'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as actionsTypes from './../redux/actioins/changeName'
class Home extends React.Component {
componentDidMount(){
this.props.changeNameAction.changeName({
id: 123,
name: "yuyang"
});
console.log(this.props.changeName);
}
render(){
return (
<div>
<Link to="/about/32234">To About</Link>
<div>hello world</div>
{this.props.changeName.name}
</div>
)
}
}
function mapStateToProps(state) {
return {
changeName: state.changeName
}
}
function mapDispathToProps(dispath) {
return {
changeNameAction: bindActionCreators(actionsTypes, dispath)
}
}
export default connect(
mapStateToProps,
mapDispathToProps
)(Home)