I'm new to react-native and I'm trying for the first time to save the states of my app.
In order to achieve this I've been suggested to use redux-persist. I expected to find more examples and topics about it in the web and I feel that my idea about how redux-persist works is not that limpid.
I've followed the short guide in the github page but once I close and re-open my app I can't see saved states values but I see the default, initial states values.
This is my app.js file:
import React, { Component } from 'react';
import { AsyncStorage } from 'react-native'
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, compose } from 'redux';
import { persistStore, autoRehydrate } from 'redux-persist';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
import Router from './Router';
class App extends Component {
render() {
const store = compose(applyMiddleware(ReduxThunk), autoRehydrate())(createStore)(reducers);
persistStore(store, {storage: AsyncStorage}, () => {
console.log('restored');
})
return (
<Provider store={store}>
<Router />
</Provider>
);
}
}
export default App;
Do I need something else?
I'd also like to know how I can console.log
all the states values inside the redux-persistor storage.
Thanks in advance