title: How to return an empty jsx element from the render function in react?
body: <p>I have a code in <code>react</code> that looks something like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class UserManagement extends React.Component {
      constructor() {
          super();
          this.state = {
              users: undefined,
          };
      }
  
      componentWillMount() {
          // load the users state with a Promise
          setTimeout(() =&gt; {
            this.setState({users: []});
          }, 800);
      }
  
      render() {
          if ( this.state.users === undefined ) {
              // until the users state is updated, I want to return an empty element
              return null;
          }
  
          // real site rendering
          return &lt;div&gt;We have users&lt;/div&gt;;
      }
  }
  
  ReactDOM.render(
    &lt;UserManagement /&gt;,
    document.getElementById("root")
  );</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;Will be blank at first while we don't have users, then show "We have users" after 800ms when we have users&lt;/div&gt;
  &lt;div id="root"&gt;&lt;/div&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My question is: How to return an empty element until the users state is returned? I tried to return <code>(null)</code> as suggested in some places, but the browser raise this error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'style' of null</p>
  </blockquote>
  
  <p>I am aware of the option to return <code>(&lt;div&gt;&lt;/div&gt;)</code>, but I am not sure that this is the best practice in this case.</p>
  
  <p>Thnaks!</p>