here is the array I am making the query to.
newArray = [
{
"value": 2554,
"label": "This is my post",
"content": "“There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain…”",
"image": "http://localhost:8888/new-site/wp-content/uploads/2023/03/Arrow-01-300x300-1.png",
"link": "http://localhost:8888/new-site/2024/02/10/this-is-my-post/",
"catagory": "newCat"
},
{
"value": 2468,
"label": "Will this work",
"content": "blah blah blah",
"image": "http://localhost:8888/new-site/wp-content/uploads/2023/03/Jody-Findley-HEADSHOT-002.png",
"link": "http://localhost:8888/new-site/2024/02/09/will-this-work/",
"catagory": "vtalk"
},
{
"value": 2037,
"label": "This is the title",
"content": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,",
"image": "http://localhost:8888/new-site/wp-content/uploads/2024/01/6W4A2713-2-scaled.jpg",
"link": "http://localhost:8888/new-site/2024/01/18/bob-smith-talk/",
"catagory": "newCat"
},
{
"value": 965,
"label": "This is not the right id",
"content": "The Arts Industry Is Worth Over 90 Billion Pounds A Year And Is One Of The Fastest Growing Industries Wednesday 17th May KS3-5 / S1-6 In the working world, there are a huge amount of creative careers available, and though it may be a competitive industry there are many opportunities. In this broadcast Simon will […]",
"image": "http://localhost:8888/new-site/wp-content/uploads/2024/01/R7A9265-2-scaled.jpg",
"link": "http://localhost:8888/new-site/2023/05/26/this-is-not-the-right-id/",
"catagory": "vtalk"
},
{
"value": 959,
"label": "Why Study RE With Alec Ryrie, Professor of the History of Christianity, University of Durham",
"content": "Religious Studies or Education is more than just a Mandatory GCSE subject – its a look into our past Tuesday 16th May KS3 Have you ever wondered why you have to study RE in school? In this broadcast, we hear from historian Prof. Alec Ryrie who talks to us about the importance of RE and […]",
"link": "http://localhost:8888/new-site/2023/05/26/why-study-re-with-alec-ryrie-professor-of-the-history-of-christianity-university-of-durham/",
"catagory": "vtalk"
},
{
"value": 957,
"label": "Engineering In Art With Dr Zoe Laughlin, Director, Institute of Making, UCL",
"content": "I love having agency in my environment and world wide – thinking about materials differently Monday 22nd May KS3-5 / S1-6 Artist and designer, Dr Zoe Laughlin was diagnosed with dyslexia at a young age and found the academic side of school difficult. She fully believes in perseverance, persistence, creativity, and following your gut to […]",
"link": "http://localhost:8888/new-site/2023/05/26/engineering-in-art-with-dr-zoe-laughlin-director-institute-of-making-ucl/",
"catagory": "vtalk"
},
{
"value": 372,
"label": "Test",
"content": "",
"image": "http://localhost:8888/new-site/wp-content/uploads/2023/03/250320231679738119.jpeg",
"link": "http://localhost:8888/new-site/2023/03/23/test/",
"catagory": "Uncategorised"
},
{
"value": 1,
"label": "Hello world!",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Iaculis eu non diam phasellus. Sollicitudin nibh sit amet commodo nulla facilisi nullam. Faucibus scelerisque eleifend donec pretium vulputate sapien nec. Vulputate sapien nec sagittis aliquam malesuada. Justo donec enim diam vulputate ut pharetra. Volutpat ac […]",
"image": "http://localhost:8888/new-site/wp-content/uploads/2023/03/buddhist-wheel.png",
"link": "http://localhost:8888/new-site/2023/03/03/hello-world/",
"catagory": "Uncategorised"
}
]
Here is my loop
function myLoop(){
const theArray = newArray;
for (var i=0; i < theArray.length; i++) {
return(
<div class="blog-stamp">
<img class="stamp-image" src={theArray[i].image} width="200" height="200" />
<RichText
tagName="h3"
class="stamp-title"
onChange={(heading) => upadateMenuItems(src, heading, para, href)}
value={theArray[i].label}
/>
<RichText
tagName="p"
class="stamp-excerpt"
onChange={(para) => upadateMenuItems(src, heading, para, href)}
value={theArray[i].content}
/>
<p class="button-parent">
<a
href={theArray[i].link}
className="sfs-button"
style={{ backgroundColor: backgroundColor, color: textColor }}
>
{'Read more'}
</a>
</p>
</div>)
}
}
I am a bit confused as the for loop should loop through the whole array and return all the values. Instead it only returns 1 record then quits.
Here is where I call the function in my js file.
<div class="blog-stamp-parent">
{
myLoop()
}
</div>
I am a newbie so please be kind. Thanks in advance.