title: Updating a variable in return() in react-native
body: <p>I am fairly new to React and React-native and I'm struggling to understand how I am supposed to update a variable in the return method.</p>
  
  <p>Currently this is my code</p>
  
  <pre><code>import React, { Component } from "react";
  import { View, StyleSheet, Platform, Text, Button } from "react-native";
  
  export default class App extends Component&lt;{}&gt; {
    constructor() {
      super();
      this.handleClick = this.handleClick.bind(this);
    }
    handleClick = test =&gt; {
      fetch("http://192.168.1.237:3000/thoughts")
        .then(res =&gt; res.json())
        .then(res =&gt; {
          return (test = JSON.stringify(res));
          return JSON.stringify(res);
        })
        .catch(error =&gt; {
          console.error(error);
        });
    };
    componentDidMount() {}
  
    render() {
      var test = 12314214;
  
      return (
        &lt;View style={[styles.container]}&gt;
          &lt;Text style={styles.text}&gt;{test}&lt;/Text&gt;
          &lt;Button
            onPress={this.handleClick.bind(this)}
            title="Learn More"
            color="#841584"
          /&gt;
        &lt;/View&gt;
      );
    }
  }
  </code></pre>
  
  <p>What I'm trying to do is to get "{ test }" updated when I click the button. The button works and if I console.log the button the test variable is updated. I'm guessing there's something fundamental missing here. Any help appreciated.</p>