forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomepage.js
32 lines (25 loc) · 912 Bytes
/
homepage.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
import React from 'react'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import {namespaceConfig} from 'fast-redux'
import Link from 'next/link'
const DEFAULT_STATE = {build: 1}
const {actionCreator, getState: getHomepageState} = namespaceConfig('homepage', DEFAULT_STATE)
const bumpBuild = actionCreator(function bumpBuild (state, increment) {
return {...state, build: state.build + increment}
})
const Homepage = ({ build, bumpBuild }) => (
<div>
<h1>Homepage</h1>
<h3>Current build: {build}</h3>
<p><button onClick={(e) => bumpBuild(1)}>Bump build!</button></p>
<Link href='/about'><a>About Us</a></Link>
</div>
)
function mapStateToProps (state) {
return getHomepageState(state)
}
function mapDispatchToProps (dispatch) {
return bindActionCreators({ bumpBuild }, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(Homepage)