import React from 'react';
import ReactDOM from 'react-dom';
import AppContainer from './components/app-container.jsx';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import summonerApp from './redux/reducers';
import InitialState from './redux/initial-state';

// initialData = localstorage.get(dataID) || {};
// let store = createStore(summonerApp, initialData, middleware());
// function middleware() {
//   on each event localstorage.save()
// }

// might be the proper place to set initial data, rather than app-container
let store = createStore(summonerApp, InitialState);

ReactDOM.render(
  <Provider store={store}>
    <AppContainer />
  </Provider>,
  document.getElementById('mountpoint')
);

import React from 'react';
import ReactDOM from 'react-dom';
import AppContainer from './components/app-container.jsx';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import summonerApp from './redux/reducers';
import InitialState from './redux/initial-state';

function LocalStorageInterface(defaultState, storeName) {
  this.defaultState = defaultState;
  this.storeName = storeName;
}

LocalStorageInterface.prototype.getSavedState = function() {
  return JSON.parse(localStorage.getItem(this.storeName)) || this.defaultState;
};

LocalStorageInterface.prototype.setSavedState = function(state) {
  localStorage.setItem(this.storeName, JSON.stringify(state));
};

const LS = new LocalStorageInterface(InitialState, 'summonerApp');

let store = createStore(summonerApp, LS.getSavedState());

store.subscribe(function() {
  LS.setSavedState(store.getState())
});

ReactDOM.render(
  <Provider store={store}>
    <AppContainer />
  </Provider>,
  document.getElementById('mountpoint')
);

Add basic interface with localStorage
Add basic interface with localStorage
