title: How to pass object array as props to a custom component in react native?
body: <p>I have fetched some data from an API as a JSON array in componentDidMount method as below.</p>
  <pre><code>componentDidMount() {
      return fetch('http://..someAPI../product/')
        .then(res =&gt; res.json())
        .then(resJson =&gt; {
          this.setState({
            isLoading: false,
            dataSource: resJson,
          });
          var objects = this.state.dataSource;
          for (var i = 0; i &lt; objects.length; i++) {
            console.log('Item Name: ' + objects[i].productName);
          }
        })
        .catch(err =&gt; {
          console.log(err);
        });
    }
  </code></pre>
  <p>In here I get console.log output as I want. Now I want to pass the array in a loop as a prop to a custom component, but it gives error.
  My render method looks like this</p>
  <pre><code>return (
        &lt;View&gt;
          &lt;Content&gt;
            {this.state.dataSource.map(item =&gt; {
              &lt;Product Name={item.productName} price={item.price}/&gt;;
            })}
          &lt;/Content&gt;
        &lt;/View&gt;
      );
  </code></pre>
  <p>My original Json object looks like this</p>
  <pre><code>[
     {
          &quot;category&quot;: [
              &quot;Food&quot;,
              &quot;Bread&quot;,
              &quot;Bun&quot;
          ],
          &quot;_id&quot;: &quot;1&quot;,
          &quot;productName&quot;: &quot;Sausage bun&quot;,
          &quot;price&quot;: 70,
          &quot;details&quot;: &quot;test product&quot;,
      },
      {
          &quot;category&quot;: [
              &quot;Food&quot;,
              &quot;Bread&quot;,
              &quot;Bun&quot;
          ],
          &quot;_id&quot;: &quot;2&quot;,
          &quot;productName&quot;: &quot;Fish Pastry&quot;,
          &quot;price&quot;: 50,
          &quot;details&quot;: &quot;test product&quot;,
      }
  ]
  </code></pre>
  <p>I want to pass these data to display the products as a loop. How can I do this? Thank you in advance!</p>