title: React Native call this.setState inside function
body: <p>I'm using a xml parser <code>react-native-xml2js</code> in react native, but this "plugin" uses a specific function for parse the xml, I wasn't found a correct way to use "this" within the function, I've tried using <code>bind()</code> in the callback but doesn't work as expected when using bind it fills my variable moments later after executed, so I don't know how to use it, this is my code:</p>
  
  <pre><code>  state = { artcicles: null }
  
    componentDidMount() {
      fetch('http://example.com/rss.xml')
        .then((response) =&gt; response.text())
        .then((response) =&gt; {
          parseString(response, function (err, result) {
            this.setState({
              articles: JSON.stringify(result.rss.channel[0].item)
            })
            console.log('RAW: '  + result.rss.channel[0].item);
            console.log('THIS: ' + this.state.articles);
          }.bind(this));
        });
    }
  </code></pre>
  
  <p>When calling <code>this.state.articles</code> in <code>render()</code> at beginning shows <code>null</code> but a second later it fills the <code>articles</code> variable but at that moment the app shows the error when I'm trying to access to the variable.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>