I'm newby to Redux. I was trying to persist data on local storage through redux-persist
. I followed the tutorial and the data stored in storage as below.
import {createStore, applyMiddleware, compose} from 'redux';
import {AsyncStorage} from 'react-native';
import {persistStore, autoRehydrate} from 'redux-persist';
import reducer from '../reducer';
var defaultState = {
todos: []
};
exports.configureStore = (initialState=defaultState) => {
var store = createStore(reducer, initialState, compose(
autoRehydrate()
));
persistStore(store, {storage: AsyncStorage});
return store;
}
And here is my App.js
.
import React, { Component } from 'react';
import {Provider} from 'react-redux';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import Main from './app/components/Main';
import {configureStore} from './app/store';
export default class App extends Component<Props> {
render() {
return (
<Provider store={configureStore()}>
<Main/>
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
But I guess, there is new update in redux-persist
. So, with this code I get the error like below.
As I understand, within new update there is no more autoRehydrate
. But I can't handle, how to update the code so it works with new version. Can you help me, please?