React Native, createStore() from AsyncStorage issue
hossammourad opened this issue · comments
Hello, I'm trying to use the createStore
function but get the values of each key from the AsyncStorage
in React Native.
import createStore from 'redux-zero';
import { AsyncStorage } from 'react-native';
const getValueFromAsyncStorage = key => {
AsyncStorage.getItem(key).then(val => {
return val ? JSON.parse(val) : [];
});
};
const store = createStore({
expenses: getValueFromAsyncStorage('expenses'),
categories: getValueFromAsyncStorage('categories')
});
export default store;
There are values for expenses
and categories
in AsyncStorage
but when I try to console.log store.getState()
, the values of each key is a promise.
Maybe it can help you. https://github.com/axetroy/redux-zero-persist
Allmost like redux-persist
@hos4m does that help? Can I close this?