millette / vdt

Next.js React Redux Rematch demo
https://vdt-dlpniaembu.now.sh/
7 stars 1 forks source link

How can I use rematch-persist? #1

Open skout90 opened 6 years ago

skout90 commented 6 years ago

Hello! Thanks for your demo project. It works well!

I use rematch-persist to save state. But it dont works well. persist dont save any state.

Could you give me some hint for this??

My code is like below.

import * as models from './models' import withRematch from 'src/store/utils/withRematch'

const persistPlugin = createRematchPersist({ throttle: 5000, version: 1, })

const initStore = (initialState = {}) => init({ plugins: [ persistPlugin ], models, redux: {initialState} })

export {initStore, withRematch}


- _app.js (in next js)
```javascript
import App, {Container} from 'next/app'
import React from 'react'

import { getPersistor } from '@rematch/persist'
import { PersistGate } from 'redux-persist/lib/integration/react'

const persistor = getPersistor()

export default class MyApp extends App {
  render () {
    const {Component, pageProps} = this.props

    return (
      <PersistGate persistor={persistor}>
        <Container>
          <Component {...pageProps} />
        </Container>
      </PersistGate>
    )
  }
}

Thanks! Have a good weekends :)

millette commented 6 years ago

Actually, I've been looking into react-persist as well but haven't finished a proper example yet. Thanks for the interest, I'll let you know, maybe this week-end.

skout90 commented 6 years ago

@millette Thanks :+1: