Skip to content

Instantly share code, notes, and snippets.

@kllaudyo
Created August 29, 2018 18:33
Show Gist options
  • Save kllaudyo/7bb33ce49d6bc2a02a502686ec02df5e to your computer and use it in GitHub Desktop.
Save kllaudyo/7bb33ce49d6bc2a02a502686ec02df5e to your computer and use it in GitHub Desktop.
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import reducer from "../reducers";
const store = createStore(
reducer,
(localStorage['store']) ?
JSON.parse(localStorage['store']) :
{},
composeWithDevTools(
applyMiddleware (thunk)
)
);
store.subscribe(()=> localStorage['store'] = JSON.stringify(store.getState()));
export default store;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment