Issue storage.getItem is not a function in React Native
See original GitHub issueHi guys, i trying to use redux persist in react native but this error shows in app opening:
error TypeError: storage.getItem is not a function at getStoredState (index.bundle?platfor…minify=false:112868) at index.bundle?platfor…minify=false:112615 at dispatch (index.bundle?platfor…minify=false:112014) at Object.dispatch (index.bundle?platfor…minify=false:114204) at Object.persist (index.bundle?platfor…minify=false:113136) at persistStore (index.bundle?platfor…minify=false:113144) at index.bundle?platfor…minify=false:111888 at loadModuleImplementation (index.bundle?platfor…ue&minify=false:271) at guardedLoadModule (index.bundle?platfor…ue&minify=false:171) at metroRequire (index.bundle?platfor…rue&minify=false:98)
My config store;
`/* eslint-disable prettier/prettier */ import {createStore, applyMiddleware} from ‘redux’; import {persistStore, persistReducer} from ‘redux-persist’; import AsyncStorage from ‘@react-native-community/async-storage’; import {createLogger} from ‘redux-logger’; import rootReducers from ‘./reducers/app’; const config = { key: ‘root’, storage: AsyncStorage, timeout: null, };
const persistedReducer = persistReducer(config, rootReducers);
// Redux: Store const store = createStore( persistedReducer, applyMiddleware( createLogger(), ), );
// Middleware: Redux Persist Persister let persistor = persistStore(store);
// Exports export { store, persistor, };`
Someone discover solution for this error?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5
Top Related StackOverflow Question
@LucasCCS thank you for the suggestion, I have already fixed the issue and the problem was not related to the libs version. In my store I have nested immutable data structures and
redux-persistdoesn’t “deserialize” it well by default.It can be fixed providing a proper transform function to
transformsoption in the config, eg. the one fromredux-persist-transform-immutablepackage.Hi @gpawlik , check version of redux-persist, my version is v6.0.0.
check my package.json:
"dependencies": { "@react-native-community/async-storage": "1.6.3", "react-redux": "^7.1.3", "redux": "^4.0.4", "redux-logger": "^3.0.6", "redux-persist": "^6.0.0", },