title: How to close Modal the React way?
body: <p>I have this modal button and when I press it a modal shows up.
  I want it to be closed if click - outside - the <code>modal-box</code>, but now it regardless if i click outside or inside the <code>modal-box</code> the modal closes down. How to make the modal box close when pressed outside <code>modal-box</code> the react way?</p>
  
  <p><a href="https://codepen.io/anon/pen/MvVjOR" rel="nofollow noreferrer">https://codepen.io/anon/pen/MvVjOR</a></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 App extends React.Component {
    constructor(){
      super()
      this.state = {
        show: false
      }
    }
    openModal() {
      this.setState( prevState =&gt; (
      {show: !prevState.show}))
    }
    closeModal() {
      this.setState({show: false})
    }
    render() {
      return (
        &lt;div&gt;
        &lt;button id='button' onClick={() =&gt; this.openModal()}&gt;the modal button&lt;/button&gt;
          {this.state.show &amp;&amp; &lt;div id='modal' onClick={() =&gt; this.closeModal()}&gt;
          &lt;div className="modal-box"&gt;
            &lt;h1&gt; I'm the AWESOME modal! &lt;/h1&gt;
          &lt;/div&gt;
        &lt;/div&gt;}
        &lt;/div&gt;
      )
    }
  }
  
  ReactDOM.render(&lt;App /&gt;, document.getElementById('root'))</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#modal {
    display: block;
    position: fixed;
    padding-top: 50px;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0 ,0 ,0 , 0.5);
  }
  
  .modal-box {
    z-index: 50;
    margin: auto;
    width: 80%;
    height: 200px;
    background-color: white;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&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;
  &lt;div id="root"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>