2019-03-12 12:42:42 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { createOvermindSSR } from 'overmind'
|
|
|
|
import { config } from '../overmind'
|
|
|
|
import Header from '../components/Header'
|
|
|
|
import Items from '../components/Items'
|
|
|
|
|
|
|
|
class Index extends React.Component {
|
|
|
|
static async getInitialProps () {
|
|
|
|
// If we want to produce some mutations we do so by instantiating
|
|
|
|
// an Overmind SSR instance, do whatever datafetching is needed and
|
|
|
|
// change the state directly. We return the mutations performed with
|
|
|
|
// "hydrate"
|
|
|
|
const overmind = createOvermindSSR(config)
|
|
|
|
|
|
|
|
overmind.state.page = 'Index'
|
2019-03-27 21:12:45 +01:00
|
|
|
overmind.state.items = [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
title: 'foo'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
title: 'bar'
|
|
|
|
}
|
|
|
|
]
|
2019-03-12 12:42:42 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
mutations: overmind.hydrate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Header />
|
|
|
|
<Items />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Index
|