title: Using if else in stateless functional component results in error when returning null
body: <p>I'm trying to conditionally return a navbar if an user is logged in. Users token is saved into localStorage and then sent into the backend system. If the backend returns an error message, it means that the user is not logged in, thus the code shouldn't render a navbar.
  However, it isn't quite working the way I'm expecting it to work and I'm really in need of someone else's knowledge at this point.</p>
  
  <p>The error message I'm getting is:</p>
  
  <p>"Nav(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."</p>
  
  <p>Nav.js</p>
  
  <pre><code>import React from 'react';
  import {Link} from 'react-router-dom';
  import {tokenCheck} from '../utils/MediaAPI';
  
  const Nav = () =&gt; {
    tokenCheck(localStorage.getItem('Login-token')).then(data =&gt; {
      if (data.message) {
        return null;
      } else {
        return (
            &lt;nav&gt;
              &lt;ul&gt;
                &lt;li&gt;
                  &lt;Link to="/home"&gt;Home&lt;/Link&gt;
                &lt;/li&gt;
                &lt;li&gt;
                  &lt;Link to="/profile"&gt;Profile&lt;/Link&gt;
                &lt;/li&gt;
                &lt;li&gt;
                  &lt;Link to="/logout"&gt;Logout&lt;/Link&gt;
                &lt;/li&gt;
              &lt;/ul&gt;
            &lt;/nav&gt;
        );
      }
    });
  };
  
  export default Nav;
  </code></pre>
  
  <p>Render from my App.js parent component.</p>
  
  <pre><code>  render() {
      return (
          &lt;Router&gt;
            &lt;Nav/&gt;
            &lt;Route exact path="/" render={(props) =&gt; (
                &lt;Login {...props} setUser={this.setUser}/&gt;
            )}/&gt;
            &lt;Route exact path="/home" render={(props) =&gt; (
                &lt;Home {...props} picArray={this.state.picArray}/&gt;
            )}/&gt;
            &lt;Route exact path="/profile" render={(props) =&gt; (
                &lt;Profile {...props} userData={this.state.user}/&gt;
            )}/&gt;
            &lt;Route exact path="/single/:id" component={Single}/&gt;
          &lt;/Router&gt;
      );
    }
  </code></pre>
  
  <p>Any help will be greatly appreciated!</p>