title: How to access array value in react?
body: <p>I have an array <code>categoryDataString</code></p>
  <pre><code>[{&quot;ID&quot;:&quot;1&quot;,&quot;Category&quot;:&quot;first&quot;},
  {&quot;ID&quot;:&quot;2&quot;,&quot;Category&quot;:&quot;second&quot;},
  {&quot;ID&quot;:&quot;3&quot;,&quot;Category&quot;:&quot;third&quot;}]
  </code></pre>
  <p>I want to access the specific value from the array. like the name of the 2nd category.</p>
  <p>I tried
  1st</p>
  <pre><code> console.log(categoryDataString[0].ID)
  </code></pre>
  <p>result</p>
  <pre><code>undefined
  </code></pre>
  <p>2nd</p>
  <pre><code>console.log(categoryDataString)
  </code></pre>
  <p>result</p>
  <pre><code>[{&quot;ID&quot;:&quot;1&quot;,&quot;Category&quot;:&quot;first&quot;},{&quot;ID&quot;:&quot;2&quot;,&quot;Category&quot;:&quot;second&quot;},{&quot;ID&quot;:&quot;3&quot;,&quot;Category&quot;:&quot;third&quot;}]
  </code></pre>
  <p>This is my code</p>
  <pre><code> const categoryDataString = JSON.stringify(categoryData)
      const categoryData = useCategoryData()
      useEffect(() =&gt; {
              setDataLoad(DataLoaded + 1)
              setSelected(categoryDataString.Category)
              console.log(categoryDataString[0].ID)
              console.log(categoryDataString)
          }, [categoryData])
  </code></pre>
  <p>This is my Itemdata.js</p>
  <pre><code>import React, { useState, useEffect } from 'react'
  import { View, Text, StyleSheet } from 'react-native'
  
  export const useCategoryData = (props) =&gt; {
      const [Category, setCategory] = useState('')
      useEffect(() =&gt; {
          fetch('https://www.amrutras.com/Category.php')
              .then((response) =&gt; response.json())
              .then((responseJson) =&gt; {
                  {
                      setCategory(responseJson)
  
                      // responseJson.map((item) =&gt; Alert.alert(item.Name))
                  }
  
                  // Showing response message coming from server after inserting records.
              })
              .catch((error) =&gt; {
                  console.error(error)
              })
      }, [])
  
      return Category
  }
  
  export default useCategoryData
  </code></pre>