How to use the overmind.createOvermindSSR function in overmind

To help you get started, we’ve selected a few overmind examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / next.js / examples / with-overmind / pages / about.js View on Github external
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() {
github zeit / next.js / examples / with-overmind / pages / index.js View on Github external
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(),
    }
github zeit / next.js / examples / with-overmind / pages / _app.js View on Github external
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