Save redux state to asyncstorage auto

This keeps you logged in between app restarts
This commit is contained in:
nikolark committed 2017-08-09 00:54:33 +02:00
1 parent cc4d3a9a41
commit 4abe648ad4
4 files changed
+23 -6

No files matched your search

+1
View File
@@ -19,6 +19,7 @@
"react-redux": "^5.0.5",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-persist": "^4.8.3",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
+10 -1
View File
@@ -4,9 +4,15 @@ import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import {persistStore, autoRehydrate} from 'redux-persist'
import {AsyncStorage} from 'react-native'
import duskenApp from "./reducers";
let store = createStore(duskenApp, applyMiddleware(...[logger, thunk]));
let store = createStore(
duskenApp,
applyMiddleware(...[logger, thunk]),
autoRehydrate()
);
export default class App extends Component {
render() {
@@ -17,3 +23,6 @@ export default class App extends Component {
)
}
}
// begin periodically persisting the store
persistStore(store, {storage: AsyncStorage});
+1 -2
View File
@@ -1,10 +1,9 @@
import React, { Component } from 'react';
import LoginContainer from "../modules/login/LoginContainer";
import Icon from 'react-native-vector-icons/SimpleLineIcons';
export default class LoginScreen extends Component {
static navigationOptions = {
title: 'Innlogging',
title: 'Logg inn',
};
onLogin = () => {
+11 -3
View File
@@ -2578,7 +2578,7 @@ json-stable-stringify@^1.0.1:
dependencies:
jsonify "~0.0.0"
json-stringify-safe@~5.0.1:
json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
@@ -2666,7 +2666,7 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"
lodash-es@^4.2.0, lodash-es@^4.2.1:
lodash-es@^4.17.4, lodash-es@^4.2.0, lodash-es@^4.2.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"
@@ -2769,7 +2769,7 @@ lodash@^3.5.0:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
lodash@^4.0.0, lodash@^4.10.1, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.16.6, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1:
lodash@^4.0.0, lodash@^4.10.1, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.16.6, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
@@ -3715,6 +3715,14 @@ redux-logger@^3.0.6:
dependencies:
deep-diff "^0.3.5"
redux-persist@^4.8.3:
version "4.8.3"
resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-4.8.3.tgz#fbad95e7582483635c91a3dd83da4789e7a09107"
dependencies:
json-stringify-safe "^5.0.1"
lodash "^4.17.4"
lodash-es "^4.17.4"
redux-thunk@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.2.0.tgz#e615a16e16b47a19a515766133d1e3e99b7852e5"