This repository was archived by the owner on Nov 16, 2018. It is now read-only.
File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
import { connect } from 'react-redux' ;
3
+ import { push } from 'react-router-redux' ;
3
4
import UserAction from '../../stores/user/UserAction' ;
4
5
import MetaAction from '../../stores/meta/MetaAction' ;
5
6
@@ -8,12 +9,15 @@ const mapStateToProps = (state) => ({
8
9
} ) ;
9
10
10
11
const mapDispatchToProps = ( dispatch ) => ( {
12
+ historyPush : ( route ) => dispatch ( push ( route ) ) ,
11
13
loadUser : ( ) => dispatch ( UserAction . loadUser ( ) ) ,
12
14
setMeta : ( meta ) => dispatch ( MetaAction . setMeta ( meta ) ) ,
13
15
} ) ;
14
16
15
17
class Home extends React . Component {
16
18
19
+ _onClickPushExampleHandler = this . _onClickPushExample . bind ( this ) ;
20
+
17
21
componentWillMount ( ) {
18
22
this . props . setMeta ( {
19
23
title : 'Home Page' ,
@@ -42,10 +46,17 @@ class Home extends React.Component {
42
46
</ button >
43
47
</ p >
44
48
</ div >
49
+ < button onClick = { this . _onClickPushExampleHandler } > { 'Go to About' } </ button >
45
50
</ div >
46
51
) ;
47
52
}
48
53
54
+ _onClickPushExample ( event ) {
55
+ event . preventDefault ( ) ;
56
+
57
+ this . props . historyPush ( '/About' ) ;
58
+ }
59
+
49
60
}
50
61
51
62
export default connect ( mapStateToProps , mapDispatchToProps ) ( Home ) ;
You can’t perform that action at this time.
0 commit comments