2017-11-23 12:41:59 +00:00
|
|
|
import React from 'react'
|
|
|
|
import { Provider } from 'mobx-react'
|
|
|
|
import { getSnapshot } from 'mobx-state-tree'
|
|
|
|
import { initStore } from '../store'
|
|
|
|
import Page from '../components/Page'
|
|
|
|
|
|
|
|
export default class Counter extends React.Component {
|
2017-12-04 23:19:53 +00:00
|
|
|
static getInitialProps ({ req }) {
|
2017-11-23 12:41:59 +00:00
|
|
|
const isServer = !!req
|
|
|
|
const store = initStore(isServer)
|
|
|
|
return { initialState: getSnapshot(store), isServer }
|
|
|
|
}
|
|
|
|
|
2017-12-04 23:19:53 +00:00
|
|
|
constructor (props) {
|
2017-11-23 12:41:59 +00:00
|
|
|
super(props)
|
|
|
|
this.store = initStore(props.isServer, props.initialState)
|
|
|
|
}
|
|
|
|
|
2017-12-04 23:19:53 +00:00
|
|
|
render () {
|
2017-11-23 12:41:59 +00:00
|
|
|
return (
|
|
|
|
<Provider store={this.store}>
|
|
|
|
<Page title='Other Page' linkTo='/' />
|
|
|
|
</Provider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|