title: Setting state in constructor ReactJS
body: <p>I have seen different variations of handling states in ReactJS tutorials. </p>
  
  <p>I have seen the following:</p>
  
  <pre><code>class App extends Component {
      constructor () {
          super()
          this.state = {
              message: null,
          };
      }    
  
      componentDidMount() {
          fetch('/api/hello')
             .then(response =&gt; response.json())
             .then(message =&gt; this.setState({ message }));
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class App extends Component {
      state = {};
  
      hello = () =&gt; {
          fetch("/api/hello")
             .then(response =&gt; response.text())
             .then(message =&gt; this.setState({ message }));
      };
  }
  </code></pre>
  
  <hr>
  
  <p>Both behave as expected, i.e. it was able to render the message from <code>/api/hello</code>. I am wondering the difference between the two where one is setting the state in the constructor and the other isn't.</p>