Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = 'About'
return {
mutations: overmind.hydrate(),
}
}
render() {
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'
overmind.state.items = [
{
id: 0,
title: 'foo',
},
{
id: 1,
title: 'bar',
},
]
return {
mutations: overmind.hydrate(),
}
constructor(props) {
super(props)
const mutations = props.pageProps.mutations || []
if (typeof window !== 'undefined') {
// On the client we just instantiate the Overmind instance and run
// the "changePage" action
this.overmind = createOvermind(config)
this.overmind.actions.changePage(mutations)
} else {
// On the server we rehydrate the mutations to an SSR instance of Overmind,
// as we do not want to run any additional logic here
this.overmind = createOvermindSSR(config)
rehydrate(this.overmind.state, mutations)
}
}
// CLIENT: After initial route, on page change