Skip to content

Commit

Permalink
Add local storage support
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej Mihajlov committed Feb 1, 2017
1 parent 98e6955 commit d4f689b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/client/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import { hashHistory } from 'react-router';
import { routerMiddleware, routerReducer as routing, push } from 'react-router-redux';
import persistState from 'redux-localstorage';
import thunk from 'redux-thunk';

import user from './reducers/user';
Expand Down Expand Up @@ -29,7 +30,7 @@ const composeEnhancers = (() => {
})();

export default function configureStore(initialState) {
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
const enhancer = composeEnhancers(applyMiddleware(...middlewares), persistState());
const rootReducer = combineReducers(reducers);

return createStore(rootReducer, initialState, enhancer);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"react-router-redux": "^4.0.7",
"redux": "^3.0.0",
"redux-actions": "^1.2.1",
"redux-localstorage": "^0.4.1",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
Expand Down

1 comment on commit d4f689b

@jschr
Copy link
Owner

@jschr jschr commented on d4f689b Feb 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to show you https://github.com/rt2zz/redux-persist in case you haven't seen it. Seems like basically the same API as redux-localstorage but the nice thing about redux-persist is you can extend to support many types of storage.

One potential application of this would be the ability to use %userData% to persist app state. The advantage would be if you wanted to persist some app state across updates / reinstalls.

I think its a good change either way just wanted to show you in case you haven't seen that lib.

Please sign in to comment.