rt2zz / redux-persist

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

After upgrading React native 0.66 Redux persist stop working on android #1358

Closed Shubhamd-Sankey closed 2 years ago

Shubhamd-Sankey commented 2 years ago

it works when my react native version is 0.64


import thunk from 'redux-thunk';
import {persistStore, persistReducer} from 'redux-persist';
import AsyncStorage from '@react-native-community/async-storage';
import {rootReducer} from '../reducer/RootReducers';

let middleWare = [thunk];

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['mainReducer'],
};

// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const persistStoreReducer = persistReducer(persistConfig, rootReducer);

export const configStore = createStore(
  persistStoreReducer,
  applyMiddleware(...middleWare),
);

export let persistor = persistStore(configStore);```
anwarhamr commented 2 years ago

I'm having this issue w/ a new project using RN 67, any luck?

dhumal436 commented 2 years ago

i solved using redux-persist-filesystem-storage instead of async storage

Aurelienlajoinie commented 2 years ago

Hello, switching to the new recommended library works for us :) Cf. Async Storage has moved to new organization: https://github.com/react-native-async-storage/async-storage

minsoo-web commented 2 years ago

i solved using redux-persist-filesystem-storage instead of async storage

You saved my life, Thanks @dhumal436

My version is below RN: 0.66.3 redux-persist: 6.0.0

my code is below

const persistConfig = {
  key: 'persist',
  storage: FilesystemStorage, // it was AsyncStorage from '@react-native-async-storage/async-storage'
  timeout: undefined,
  keyPrefix: '',
};

When use AsnycStorage, It was fine all ios version and device, and Android also

but, some old Android version is not working properly

I changed AsyncStorage to redux-persist-filesystem-storage It is all fine

Thanks