title: React, persisting redux state or reauthenticating via jwt to keep a user logged in?
body: <p>I want to make sure this process is a good practice, and if not how can I improve it?  So the scenario I have is the user logs in to the website and on return of of a successful login response, I am storing the access token and refresh token in local storage client side.  Upon completion of storing the tokens, I think call an action creator to set me auth reducer to have isAuthenticated true.  </p>
  
  <p>Option 1, If the user closes the browser down and comes back while the access token has not expired, I would like to reauthenticate the user and automatically log that person in.</p>
  
  <p>Option 2, I was thinking of was to use a package like redux-persist and would persist my auth redux state, but then if the tokens are invalid I would have to fail the authentication at some point and then set the reducer state back to not authenticated.</p>
  
  <p>Would love to hear other peoples insight on how they are handling this scenario in a environment containing react, redux and jwt's.</p>
  
  <p>So in my App.jsx I have something that looks like this:</p>
  
  <pre><code>class App extends Component {
      componentDidMount() {
          const accessToken = localStorage.getItem('access_token');
          if (accessToken !== null) {
              //Here I would make some API call with either the access or refresh token
              //And if it's valid I would set the auth reducer to isAuthenticated.  Or I could
              //just check for the existance of the local storage item and set it the
              //reducer to isAuthenticated = true, do either of these make sense to do?
          }
      }
      render() {
          return (
              &lt;Router&gt;
                  &lt;NavMenu&gt;
                      &lt;Switch&gt;
                          &lt;Route exact path='/' component={ Home }/&gt;
                          &lt;Route exact path='*' component={ NotFound } /&gt;
                      &lt;/Switch&gt;
                  &lt;/NavMenu&gt;
              &lt;/Router&gt;
          );
      }
  </code></pre>