import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { browserHistory, Router } from 'react-router'
import { Provider } from 'react-redux'
import { persistStore } from 'redux-persist'

class AppContainer extends Component {
  static propTypes = {
    routes : PropTypes.object.isRequired,
    store  : PropTypes.object.isRequired
  }

  constructor (props) {
    super(props)
    this.state = { rehydrated: false }
  }

  componentWillMount () {
    const { store } = this.props

    // begin periodically persisting the store
    window._persistor = persistStore(store, null, () => {
      this.setState({ rehydrated: true })

      // if it looks like we have/had a valid session
      if (store.getState().user.userId !== null) {
        window._socket.open()
      }
    })
  }

  render () {
    const { routes, store } = this.props

    if (!this.state.rehydrated) {
      return (<div>Loading...</div>)
    }

    return (
      <Provider store={store}>
        <div style={{ height: '100%' }}>
          <Router history={browserHistory} children={routes} />
        </div>
      </Provider>
    )
  }
}

export default AppContainer

@@ -206,16 +206,81 @@
 persist'
+%0Aimport %7B PersistGate %7D from 'redux-persist/es/integration/react'
 %0A%0Aclass 
@@ -427,93 +427,8 @@
  %7D%0A%0A
-  constructor (props) %7B%0A    super(props)%0A    this.state = %7B rehydrated: false %7D%0A  %7D%0A%0A
   co
@@ -592,51 +592,8 @@
 %3E %7B%0A
-      this.setState(%7B rehydrated: true %7D)%0A%0A
     
@@ -807,126 +807,146 @@
     
-if (!this.state.rehydrated) %7B%0A      return (%3Cdiv%3ELoading...%3C/div%3E)%0A    
+return (%0A      %3CProvider store=%7Bstore%7D%3E%0A        %3CPersistGate%0A          loading=%7Bnull
 %7D%0A
-%0A
     
-return (%0A      %3CProvider 
+      persi
 stor
-e
 =%7B
-store%7D%3E%0A
+window._persistor%7D%0A        %3E%0A  
     
@@ -982,16 +982,18 @@
 0%25' %7D%7D%3E%0A
+  
         
@@ -1060,15 +1060,40 @@
     
+  
 %3C/div%3E%0A
+        %3C/PersistGate%3E%0A
     

Use PersistGate from redux-persist