redux-persist asyncLocalStorage requires a global localStorage object
See original GitHub issueI am having this error:
redux-persist asyncLocalStorage requires a global localStorage object. Either use a different storage backend or if this is a universal redux application you probably should conditionally persist like so: https://gist.github.com/rt2zz/ac9eb396793f95ff3c3b
i am using the docs to do the following code and i can’t find what i am doing wrong:
`‘use strict’;
import React, { Component } from ‘react’; import {persistStore, autoRehydrate} from ‘redux-persist’; import {AsyncStorage} from ‘react-native’; import thunk from ‘redux-thunk’; import { applyMiddleware, createStore, compose } from ‘redux’; import { composeWithDevTools } from ‘remote-redux-devtools’; import rootReducer from ‘addaps/app/redux/reducers/rootReducer.js’;
const composeEnhancers = composeWithDevTools({ realtime: true, port: 8000 });
const store = createStore(rootReducer, {}, composeEnhancers( autoRehydrate(), applyMiddleware(thunk), ));
if (typeof self === ‘object’) persistStore(store, [{storage: AsyncStorage, whitelist: [‘system’]}, console.log(‘finish persist’) ])
export default store; `
any ideas? thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Just re-read the docs - I guess for ReactNative we need to specify which storage engine we’re going to be using; in my case AsyncStorage. So I just changed my
to
then its all good.
Thanks! Just quick tip, check if you’ve imported AsyncStorage or AsynchStorage 😄