Logins and logouts (sessions) are working
This commit is contained in:
+12
-2
@@ -7,17 +7,27 @@ import thunk from 'redux-thunk';
|
||||
import DevTools from './dev_tools.jsx';
|
||||
import App from './components/app.jsx';
|
||||
|
||||
import reducer from './reducers/reducer.jsx';
|
||||
import reducer from './reducers/reducer.js';
|
||||
|
||||
//persistence
|
||||
let ITEM_NAME = 'account.kingdombattles';
|
||||
let account = localStorage.getItem(ITEM_NAME);
|
||||
account = account ? JSON.parse(account) : {};
|
||||
|
||||
var store = createStore(
|
||||
reducer,
|
||||
{}, //initial state
|
||||
{ account: account }, //initial state
|
||||
compose(
|
||||
applyMiddleware(thunk),
|
||||
DevTools.instrument()
|
||||
)
|
||||
);
|
||||
|
||||
//persistence
|
||||
store.subscribe(() => {
|
||||
localStorage.setItem(ITEM_NAME, JSON.stringify(store.getState().account));
|
||||
});
|
||||
|
||||
//start the process
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
|
||||
Reference in New Issue
Block a user