title: I got "Cannot read properties of undefined (reading 'map')" by using map for looping
body: <p>I'm creating a custom block and i have used this code to get the data from an array. Please see the code below.</p>
  <pre class="lang-js prettyprint-override"><code>export default function Edit(props) {
      if (!props.attributes.categories) {
          wp.apiFetch({
              url: '../wp-json/wp/v2/cuspost'
          }).then(categories =&gt; {
              props.setAttributes({
                  categories: categories
              })
          });
      }
  
      console.log(props.attributes.categories);
  
      return ( &lt;&gt;
                  &lt;div className={ props.className }&gt;
                      &lt;lable&gt;Select TablePress table&lt;/lable&gt;
                      &lt;form&gt;
                          &lt;select&gt;
                          {
                              props.attributes.categories.map( table =&gt; {
  
                                  return (
                                      &lt;option value=&quot;{table.id}&quot; key=&quot;{table.id}&quot;&gt;
                                          { table.title }
                                      &lt;/option&gt;
                                  );
                              } )
                          }
                          &lt;/select&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/&gt; );
  }
  </code></pre>
  <p>After this i got this error &quot; <code>Cannot read properties of undefined (reading 'map')</code> &quot;. Am I skip anything to define? Please help to solve this one.</p>