title: Rendering React components according to Amplify logged in user
body: <p>How can I render different React components based on the output of <code>Amplify.currentAuthenticatedUser()</code> (or similar equivalent) ?</p>
  <p>The following works -</p>
  <pre><code>render() {
      if (Auth.user) {
          return (
          &lt;LoggedInContainer pages={this.state.pages} /&gt;
          );
      } else {
          return (
          &lt;LoginForm loginHandler={this.login} /&gt;
          );
      };
  }
  </code></pre>
  <p>but if I refresh the page the session seems to be lost and I have to re- login, ie I think referencing <code>Auth.user</code> is sub- optimal.</p>
  <p>If I try the following -</p>
  <pre><code>render() {
      Auth.currentAuthenticatedUser().then(user =&gt; {
          return (
          &lt;LoggedInContainer pages={this.state.pages} /&gt;
          );
      }).catch(e =&gt; {
          return (
          &lt;LoginForm loginHandler={this.login} /&gt;
          );
      });
  }
  </code></pre>
  <p>then I get <code>Your render method should have return statement  react/require-render-return</code></p>
  <p>If I try the following -</p>
  <pre><code>getCurrentUser() {
      Auth.currentAuthenticatedUser().then(user =&gt; {
          console.log(user.attributes.email);
          return user.attributes.email;
      }).catch(e =&gt; {
          return undefined;
      });
  }
  render() {
      if (this.getCurrentUser()) {
          return (
          &lt;LoggedInContainer pages={this.state.pages} /&gt;
          );
      } else {
          return (
          &lt;LoginForm loginHandler={this.login} /&gt;
          );
      };
  }
  </code></pre>
  <p>then I never get logged in because the output of <code>getCurrentUser</code> is always <code>undefined</code>, <em>despite</em> the fact that the <code>console.log()</code> line in <code>getCurrentUser</code> prints out the correct email of the user!</p>
  <p>Is there no simple way to get the value of the current Amplify logged- in user, and render different React components according to its value ?</p>