rt2zz / redux-persist

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

My store is being hydrated twice, and not the same twice. #995

Open toringo opened 5 years ago

toringo commented 5 years ago

My store is being hydrated twice. store.js :

const config = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['account', 'session', 'task', 'inspiration'],
  blacklist: [],
  timeout: null,
};
if (__DEV__) {
  const xhr = global.originalXMLHttpRequest
      ? global.originalXMLHttpRequest
      : global.XMLHttpRequest;
  global.XMLHttpRequest = xhr;
}

const reducers = persistReducer(config, rootReducer);
const enhancers = [applyMiddleware(...middleware)];

const initialState = {
};
const persistConfig = { enhancers };
const store = createStore(reducers, initialState, compose(...enhancers));
const persistor = persistStore(store, persistConfig, () => {
  // console.log('Test', store.getState());
});

StoreProvider.js :

  render() {
    return (
      <Provider store={store}>
        <PersistGate loading={<ActivityIndicator style={styles.loading} />} persistor={persistor}>
          {this.props.children}
        </PersistGate>
      </Provider>);
  }

Result

image

The problem is similar to #909 . Any idea? Excuse me @rt2zz @Andarist

Graig123git commented 5 years ago

can anyone provide a solution this, I am experiencing the same issue as well.