title: How to access all elements from dictionary - ReactJS
body: <p>API returns parents and their children in a dictionary.</p>
  <p>// Dictionary with string as its key(parent) and list of strings(children) as its value as below:</p>
  <pre><code>        { &quot;A&quot;: [&quot;AQ11&quot;], &quot;B&quot;: [], &quot;C&quot;: [&quot;CN22&quot;, &quot;CL33&quot;] }
  </code></pre>
  <p>I have two questions, Have I set my data structure correct to hold the API values (does it add all parents and children to dictionary).</p>
  <p>And how do I iterate thru all elements in the dictionary. Thanks.</p>
  <p>Below is my state:</p>
  <pre><code>    this.state = {
        items:
            {
                  parentItemNo: &quot;&quot;,
                  childItemNo: [],              
            }
  </code></pre>
  <pre><code>  return (
          &lt;div&gt;                      
              {this.state.items.parentItemNo},
              {this.state.items.childItemNo[1]}
          &lt;/div&gt;
       )
  </code></pre>
  <p>Above returns only the last element of the dictionary -&gt; C, CL33.</p>
  <p>I have changed my data structure now as below as advised.</p>
  <pre><code>items:
        [{
              parentItemNo: &quot;&quot;,
              childItemNo: [],              
        }]
  </code></pre>