1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-refnux/pages/page2.js
Tim Neutkens 9c4eefcdbf
Add prettier for examples directory (#5909)
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
2018-12-17 17:34:32 +01:00

29 lines
756 B
JavaScript

import { connect } from 'refnux'
import Link from 'next/link'
import withRefnux from '../helpers/withRefnux'
import getInitialState from '../store/getInitialState'
// actions
import counterIncrement from '../store/counterIncrement'
import setTitle from '../store/setTitle'
const Page2 = connect((state, dispatch) => (
<div>
<h3>{state.title}</h3>
<p>Current state: {JSON.stringify(state, null, 2)}</p>
<button onClick={() => dispatch(counterIncrement)}>Increment</button>
<Link href='/page1'>
<button>go to page 2</button>
</Link>
</div>
))
Page2.getInitialProps = async function (context) {
const { store } = context
store.dispatch(setTitle('Page 2'))
return {}
}
export default withRefnux(getInitialState, Page2)