title: iterate over JSON array in react-native
body: <p>I've come across a problem working in react native. I've parsed a JSON object and need to iterate over an array nested inside it.I want to get all <code>profiles</code> objects in a list.</p>
  
  <p>i tried with the below code but its not fetching profiles object .how to print all profiles objects in  list?</p>
  
  <p>code:</p>
  
  <pre><code>import React, { Component } from 'react';
  import { AppRegistry, StyleSheet, Modal, Image, Platform } from 'react-native';
  import { Spinner, Text, View, Content, Container,Item,Header,Body, Title, Button, Icon, InputGroup, Input, ListItem, List, Radio, CheckBox, Thumbnail, Card, CardItem, H3 } from 'native-base';
  
   class Profile extends Component {
      constructor(props) {
          super(props);
          this.state = {
              radio1 : true,
              check1: false,
              modalVisible: false,
              search: 'nativebase',
              selectedItem: undefined,
              results: {
                  items: []
              }
          }
      }
  
      setModalVisible(visible, x) {
          this.setState({
              modalVisible: visible,
              selectedItem: x
          });
      }
  
      toggleCheck() {
          this.setState({
              check1 : !this.state.check1
          })
      }
      componentDidMount() {
  
          var that = this;
          this.search();
  
      }
  
      search() {
          // Set loading to true when the search starts to display a Spinner
          this.setState({
              loading: true
          });
  
          var that = this;
          return fetch('https://mysite.in/api/profilematch/25/')
              .then((response) =&gt; response.json())
              .then((responseJson) =&gt; {
                  // Store the results in the state variable results and set loading to 
                  // false to remove the spinner and display the list of repositories
                  that.setState({
                      results: responseJson,
                      loading: false
                  });
  
                  return responseJson;
              })
              .catch((error) =&gt; {
  
                  that.setState({
                      loading: false
                  });
  
                  console.error(error);
          });
      }
  
      render() {
  
          var that = this;
          return (
              &lt;Container&gt;
                  &lt;Content&gt;
                  &lt;List&gt;
                      {this.state.loading? &lt;Spinner /&gt; : &lt;List dataArray={this.state.results} renderRow={(results) =&gt;
                                  &lt;ListItem button onPress={()=&gt;this.setModalVisible(true, item)} &gt;
                                      &lt;Thumbnail square size={80} source={{uri: results.avatar_url}} /&gt;
                                      &lt;Text&gt;Name: &lt;Text style={{fontWeight: '600', color: '#46ee4b'}}&gt;{results}&lt;/Text&gt;&lt;/Text&gt;
                                       &lt;Body&gt;
                                      &lt;Text&gt;{results.sur_name}&lt;/Text&gt;
  
                                      &lt;/Body&gt;
                                  &lt;/ListItem&gt;
                              } /&gt;}
                  &lt;/List&gt;
              &lt;/Content&gt;
              &lt;/Container&gt;
           );
       }
   }
  const styles = StyleSheet.create({
      header : {
          marginLeft: -5,
          marginTop: 5,
          marginBottom: (Platform.OS==='ios') ? -7 : 0,
          lineHeight: 24,
          color: '#5357b6'
      },
      modalImage: {
          resizeMode: 'contain',
          height: 200
      },
      bold: {
          fontWeight: '600'
      },
      negativeMargin: {
          marginBottom: -10
      }
  });
  
  module.exports = Profile;
  </code></pre>
  
  <p>json:</p>
  
  <pre><code>[
      {
          "id": 4,
          "profiles": [
              {
                  "id": 18,
                  "first_name": "sweta",
                   "is_active": true
  
              },
              {
                  "id": 20,
                  "first_name": "Hiteshi",
                   "is_active": true
              },
              {
                  "id": 3,
                  "first_name": "Sneha",
                  "is_active": true
              }
          ],
          "user": 25
      }
  ]
  </code></pre>
  
  <p>All i want to do is to print <code>profiles</code> objects in a list.</p>