-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathpage1.js
86 lines (76 loc) · 1.71 KB
/
page1.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// @flow
// #region imports
import { PureComponent } from 'react';
import { bindActionCreators } from 'redux';
import withRedux from 'next-redux-wrapper';
import configureStore from '../redux/store/configureStore';
import * as userAuthActions from '../redux/modules/userAuth';
import Layout from '../components/layout/Layout';
import Header from '../components/header/Header';
import Button from 'react-bootstrap/lib/Button';
import Router from 'next/router';
// #endregion
// #region flow types
type Props = {
// userAuth:
isAuthenticated: boolean,
disconnectUser: () => any,
...any
};
type State = any;
// #endregion
class Page1 extends PureComponent<Props, State> {
// #region component lifecycle methods
render() {
return (
<Layout>
<Header />
<h2>
Page1 here
</h2>
<Button
bsStyle="primary"
onClick={this.goBackHome}
>
go back home
</Button>
</Layout>
);
}
// #endregion
// html elements events
goBackHome = (
event: SyntheticEvent<>
): void => {
if (event) {
event.preventDefault();
}
Router.push('/');
}
// #endregion
}
// #region redux state and dispatch map to props
const mapStateToProps = (
state: any
) => ({
// userAuth:
isAuthenticated: state.userAuth.isAuthenticated
});
const mapDispatchToProps = (
dispatch: (...any) => any
) => {
return {
...bindActionCreators(
{
// userAuth:
...userAuthActions
},
dispatch)
};
};
// #endregion
export default withRedux(
configureStore,
mapStateToProps,
mapDispatchToProps
)(Page1);