title: How do I set a rendered item as a state in React Native?
body: <p>Is it possible to set the state inside the <code>render()</code> or would I have to do it while <code>fetching</code>? I haven't found an similar questions to mine probably because I am not asking the right question, but I hope this makes sense. Here is my code:</p>
  
  <pre><code>&lt;FlatList
  
             data={ this.state.newimage}
  
             ItemSeparatorComponent = {this.FlatListItemSeparator}
  
  
             renderItem={({item}) =&gt; &lt;View&gt;
               //Want to set item.id as a state
               &lt;Text&gt;{item.id}&lt;/Text&gt;
               &lt;/View&gt;
               /&gt;
  </code></pre>
  
  <p>And if needed here is my <code>fetch</code>:</p>
  
  <pre><code>fetch(`https://www.example.com/React/images.php`, {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
  }).then((response) =&gt; response.json())
      .then((responseJson) =&gt; {
  
       this.setState({
          dataSource: responseJson, //&lt;-- This is uneeded data
          newimage:  responseJson[0].image.map(item =&gt; ({ ...item, progress: new Animated.Value(0), unprogress: new Animated.Value(1) }))
          //mapping is only for animating the likes, adds a unique progress to the json array
         },function() {
  
         });
  
  
  
  }).catch((error) =&gt; {
    //console.error(error);
  });
  </code></pre>
  
  <p>All of the JSON code: </p>
  
  <pre><code>[{"id":"16","first_name":"Bob","last_name":"Jones","username":"HiBill","image":[{"id":"10","images":"Emerson live in the sunshine swim in the sea drink the wild air.jpg","note":"Hello","tags":"sunshine"},{"id":"12","images":"on top of the mountains and beneath the stars.jpg","note":"Ah peaceful ","tags":"mountains"},{"id":"35","images":"8D11AE92-270E-4F98-846A-B9BED75AD550.jpeg","note":"Just be yourself \ud83d\udc4c","tags":"Happy"}
  </code></pre>