How to use the overmind.rehydrate 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 / overmind / index.js View on Github external
changePage({ state }, mutations) {
      rehydrate(state, mutations || [])

      switch (state.page) {
        case 'Index':
          // Do some additional logic
          break
        case 'About':
          // Do some additional logic
          break
        default:
          break
      }
    },
  },
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