Ecommerce Shopify WordPress Discussion

How can I get a const to load after my map function has finished?

I've been working on this for the last few days. It took me a while to figure out that my const is loading before my map function finishes loading. Here is my const and map function in my edit.js file const blockProps = useBlockProps(); const { backgroundColor, textColor, selectedValue, myNumber, menuItems } = attributes; const updateAttributes = (src, heading, para, href, index) => { const theAttributeUpdate = [...menuItems]; theAttributeUpdate[index] = { image: src, header: heading, excerpt: para, link: href }; setAttributes({menuItems: theAttributeUpdate}) } ... {newArray.filter((m, idx) => m.catagory == selectedValue).map((m) => { return ( <div class="blog-stamp"> <img class="stamp-image" src={m.image} width="200" height="200" /> <RichText tagName="h3" class="stamp-title" onChange={(heading) => updateAttributes(src, heading, para, href)} value={m.label} /> <RichText tagName="p" class="stamp-excerpt" onChange={(para) => updateAttributes(src, heading, para, href)} value={m.content} /> <p class="button-parent"> <a href={m.link} className="sfs-button" style={{ backgroundColor: backgroundColor, color: textColor }} > {'Read more'} </a> </p> </div>) })} The const is placed above my return statement. I believe if I can get it to load after my map function it will save an array of attributes so I can use them in my save.js file. I am a newbie. So, any help is greatly appriciated.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.