title: Saving only a particular piece of state in localStorage w/ Redux
body: <p>How to save in localStorage using Redux, only a particular piece of state?</p>
  
  <p>For example, my state in <strong>list</strong> reducer is defined as follows:</p>
  
  <pre><code>state = {
      companies: [],
      currentDisplay: '',
      recordNotFound: false,
    }
  </code></pre>
  
  <p>This is my combineReducer file:</p>
  
  <pre><code>const rootReducer = combineReducers({
    list: listReducer,
    form: formReducer
  })
  </code></pre>
  
  <p>localStorage.js:</p>
  
  <pre><code>export const loadState = () =&gt; {
    try {
      const serializedState = localStorage.getItem('state')
      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('state', serializedState)
    } catch (err) {
      // to define
    }
  }
  </code></pre>
  
  <p>And after browser reloads I want only <code>companies: [{obj1}, {obj2}, ...]</code> array to be preloaded and the rest of state reset to default values f.e. <code>currentDisplay: ''</code> to be equal ''.</p>
  
  <p>Right now responsible for this operation code looks like this:</p>
  
  <pre><code>store.subscribe(() =&gt; {
    saveState({
      list: store.getState().list
    })
  })
  </code></pre>
  
  <p>And it stores the whole list obviously... 
  I guess I could easily reset these parameters in React using setState(), but would like to do this properly. </p>