import storage from 'redux-persist/lib/storage' not working
See original GitHub issueI am using the following: { “native-base”: “^2.13.5”, “react”: “16.8.6”, “react-native”: “0.60.5”, “react-redux”: “^7.1.1”, “redux”: “^4.0.4”, “redux-logger”: “^3.0.6”, “redux-persist”: “^6.0.0”, “redux-thunk”: “^2.3.0”, } , but when importing: import storage from ‘redux-persist/lib/storage’ I get the error “redux-persist failed to create sync storage. falling back to noop storage.”
inquire a bit into your code and observe the following in the file “redux-persist/lib/storage/getStorage.js” in
function hasStorage(storageType) {
if ((typeof self === "undefined" ? "undefined" : _typeof(self)) !== 'object' || !(storageType in self)) {
return false;
}
...
}
apparently this is true: !(storageType in self), that is storageType is not in self
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (1 by maintainers)
In redux-persist v6, you try changing as follows: import storage from ‘redux-persist/lib/storage’; => import AsyncStorage from ‘@react-native-community/async-storage’;
const persistConfig = { //… storage, } => const persistConfig = { //… storage: AsyncStorage, }
I also experience the same error with
storage: AsyncStorage
configuration on redux-persist v6 and RN 0.61.4. @rt2zz What could be the reason?