rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.93k stars 866 forks source link

How to resolve this ? Does redux-persist works with saga #156

Closed renganatha10 closed 7 years ago

renganatha10 commented 8 years ago

The code mentioned is my configurestore.js. I am getting a weird error as mentioned in image. I don't its due to immutablejs or sagas. What changes i have to make in order to get rid of this error and state is not getting persisted

simulator screen shot aug 25 2016 12 52 15 pm

import { createStore, applyMiddleware, compose } from 'redux';
import { fromJS } from 'immutable';
import createSagaMiddleware from 'redux-saga';
import devTools from 'remote-redux-devtools';
import { persistStore, autoRehydrate } from 'redux-persist';
import businessLogic from 'business-logic';
import createReducer from './reducers';
import { AsyncStorage } from 'react-native';
export default function configureStore(initialState = fromJS({ })) {
  const sagaMiddleware = createSagaMiddleware();
  const enhancer = compose(applyMiddleware(sagaMiddleware), autoRehydrate(), devTools());
  const store = createStore(createReducer, initialState, enhancer);
  sagaMiddleware.run(businessLogic.sagas);
  persistStore(store, { storage: AsyncStorage }, () => {
    console.log('restored');
  });

  devTools.updateStore(store);
  return store;
}
rt2zz commented 8 years ago

is your top level state an immutablejs Map? this is currently an unsupported data structure, you can either a) help contribute to the discussion for supporting immutable in redux-persist b) switch to redux-storage which does a similar thing and has immutable support

renganatha10 commented 8 years ago

How about redux-persist-transform-immutable and redux-persist-immutable-state ? Will these packages will be helpful ?

rt2zz commented 7 years ago

now in alpha: https://github.com/rt2zz/redux-persist-immutable

that package is a drop in replacement for redux-persist with full immutablejs support!