title: New React Context API + LocalStorage + Subscribe (Replacement for Redux)
body: <p>I have an app using Redux. Is stores the global state as shown below:</p>
  
  <p>Create Store:</p>
  
  <pre><code>import {createStore, applyMiddleware} from 'redux';
  import rootReducer from '../reducers';
  import thunk from 'redux-thunk';
  
  const configureStore = initialState =&gt; {
    return createStore(
      rootReducer,
      initialState,
      applyMiddleware(thunk)
    );
  };
  
  export default configureStore;
  </code></pre>
  
  <p>Handles Local Storage</p>
  
  <pre><code>  const storageName = 'xxxState';
    export const loadState = () =&gt; {
    try {
      const serializedState = localStorage.getItem(storageName);
      if (serializedState === null) {
        return undefined;
      }
      return JSON.parse(serializedState);
    } catch(err) {
      return undefined;
    }
  };
  
  export const saveState = state =&gt; {
    try {
      const serializedState = JSON.stringify(state);
      localStorage.setItem(storageName, serializedState);
    } catch(err) {
      throw err;
    }
  };
  </code></pre>
  
  <p>Finaly starts the app session:</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import Start from './start';
  import { Provider } from 'react-redux';
  import configureStore from './store/configureStore';
  import { loadState, saveState } from './store/localStorage';
  import throttle from 'lodash/throttle';
  
  const persistedState = loadState();
  
  const store = configureStore(persistedState);
  store.subscribe(throttle(() =&gt; {
    saveState(store.getState());
  }, 1000));
  
  ReactDOM.render(
    &lt;Provider store={store}&gt;
      &lt;Start /&gt;
    &lt;/Provider&gt;,
    document.getElementById('root'));
  </code></pre>
  
  <p>It works perfectly. So my question is: Is there any possibility to do the same with the new React Context API?</p>
  
  <p>I am pretty confortable using the new context, I just want to know about store, localstorage, subscribe. So the the state is persisted even when the user leaves the app.</p>