title: How can I use setState in react-native after fetching new data?
body: <p>In order to learn about react-native I'm trying to build a simple application.</p>
  
  <p>This application initially prints "HELLO WORLD", afterwards it replaces this text with the contents of a json file that it fetches (in my test it contains {'Goodbye':'World'}).</p>
  
  <pre><code>import React, { Component } from 'react';
  import {
    AppRegistry,
    Text,
    View,
  } from 'react-native';
  
  class FetchTextTest extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        content: "HELLO WORLD",
      };
      fetch('http://echo.jsontest.com/goodbye/world').then(function(response) {
            response.json().then(function(data) {
              this.setState({content: JSON.stringfy(data)});
          });
      });
    }
    render() {
      return (
        &lt;Text&gt;{this.state.content}&lt;/Text&gt;
      )
    }
  }
  
  AppRegistry.registerComponent('FetchTextTest', () =&gt; FetchTextTest);
  </code></pre>
  
  <p>This works in that it displays HELLO WORLD and then fetches the json, but I don't manage to get it to display the new message. Instead I get this error:</p>
  
  <pre><code>Possible unhandles Promise Rejection (id: 0): TypeError: undefined is not a function (evaluating 'this.setState
  </code></pre>
  
  <p>I feel like I'm doing it wrong. Am I not supposed to call setState from inside the constructor? Am I not getting the right context?</p>
  
  <p>What is the expected way of doing this?</p>