The issue is that your syntax is invalid, you should have something like this :

var links = [
  { endpoint: '/america' },
  { endpoint: '/canada' },
  { endpoint: '/norway' },
  { endpoint: '/bahamas' }
];

class Navigation extends React.Component {
  render() {
    const listItems = links.map((link) =>
        <li key={link.endpoint}>{link.endpoint}</li> 
    );
    return (
      <div className="navigation">
        <ul>
          {listItems}
        </ul>
      </div>
    );
}
Answer from Daniel Andrei on Stack Overflow
🌐
Medium
medium.com › how-to-react › different-ways-to-loop-through-arrays-and-objects-in-react-39bcd870ccf
Different ways to loop through arrays and objects in React | by Manish Mandal | How To React | Medium
October 5, 2020 - I have used the arrow function for a shorter version of my code you can also use the normal javascript function. Both will give the same result. The for loop is executed as long as a condition is true.
Discussions

React iterate through object nested in array
I’m working with some JSON data in a React app using Axios and I am having trouble iterating through an object nested in an array. I think some variation of .map or Object.keys would work but I am stuck. I’ve made a Stack Overflow post Any ideas on how to fix this? More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
March 8, 2018
TypeScript + React.js -- how do you iterate over an array of objects with map() in order to render content?
useState(null); More on reddit.com
🌐 r/typescript
11
1
January 5, 2022
reactjs - How do i loop through an array of objects in react - Stack Overflow
I want to loop through the array of objects in my React code. I'm using getStaticProps() to fetch my data from an online fake API server. I'm using nextjs for my code. How do I do this with for or ... More on stackoverflow.com
🌐 stackoverflow.com
Loop through an array of objects and compare values. If value is not found, execute something else.
You can use .find(): const found = loc.find(({ storeNumber }) => storeNumber === sn); if (found) { //execute some code } Or a for-loop with a break: for (let i = 0; i < loc.length; i++) { if (loc[i].storeNumber === sn) { //execute some code break; } } More on reddit.com
🌐 r/learnjavascript
7
1
May 17, 2022
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Loop through Array within Object React - JavaScript
August 27, 2022 - Hi, I’m very new to React, I’m working on a project where I’m fetching data from an API then display is on a table. there is a array within the object returned and the indexes are mixed up i.e value in array [0] is ‘BMW’ and in a different object returned array [0] is ‘Grey’. therefore i would like to loop through this array the give a condition as to what data i want to display. is this possible and if so how? the image attached is how I’m rendering my current display but the data output is wr...
🌐
Bobby Hadz
bobbyhadz.com › blog › react-loop-through-array-of-objects
Loop through an Array of Objects in React | bobbyhadz
The function we passed to the Array.map() method gets called for each element in the array. On each iteration, we set the key prop on the outermost element to a unique value, and rendered the values of the object.
🌐
DhiWise
dhiwise.com › post › mastering-react-looping-through-array-a-comprehensive-guide
Understanding React Looping Through Array
January 10, 2024 - Using the map function, developers can transform array items into components, which can be rendered in the app's return block. Consider the following example where we create a list of TodoItem components from an array of todo objects...
🌐
UpStack
upstackhq.com › upstack blog › software development
Iterating On Objects In React
See the example below for how we might use this to loop over an object’s enumerable properties to access its values. const foobar = { foo: 3, bar: 'seven', fizz: [1, 'b', false] } for (val in foobar) { console.log(`foobar[${val}] = ${foobar[val]}`); } But perhaps we wish to chain together some transformations on an object – its keys or its values. In these cases, we can use the following Object built-in methods to get an array of what we need; Object.keys and Object.values, respectively.
🌐
Stack Fan
stackfan.com › home › blog › how to loop through an array of objects in react
How to loop through an array of objects in React | Stack Fan
November 9, 2022 - The easiest way to loop through an array of objects in React is using the array’s map function to display a component for each item in the array.
Find elsewhere
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
React iterate through object nested in array - JavaScript
March 8, 2018 - I’m working with some JSON data in a React app using Axios and I am having trouble iterating through an object nested in an array. I think some variation of .map or Object.keys would work but I am stuck. I’ve made a Sta…
🌐
Simple Front-End
simplefrontend.com › home › loop through array of objects in react
Loop through array of objects in React - Three different ways
June 23, 2023 - A great advantage of using map() method (over forEach() method) is that you can loop through an array of objects within JSX, as long as the expression is wrapped with curly braces. To recap: map() will go through every item in the array, run callback function on it, and return new array with ...
🌐
Reddit
reddit.com › r/typescript › typescript + react.js -- how do you iterate over an array of objects with map() in order to render content?
r/typescript on Reddit: TypeScript + React.js -- how do you iterate over an array of objects with map() in order to render content?
January 5, 2022 -

Hi, I have not been able to get any sort of clarity on this. Maybe someone here can help.

So, I need to fetch an API and return a list of products in a store, and then render that out to the user. In regular React this is easy, but I started learning TypeScript and it is throwing me for a loop.

I have the following interfaces + useState:

interface ProductInterface {
    id: string;
    fields: {
        company: string;
        featured: boolean;
        name: string;
        price: number;
    }
}
interface ProductsArrayInterface {
    products: ProductInterface[];
}
const [products, setProducts] = useState<ProductsArrayInterface|null>(null);

After calling the API I do setProducts(products) and then try to render it like so:

{products && products.map((product:any) => {
    const {id, fields} = product;
    return (
        <article key={id}>
            <h4>{fields.name}</h4>
            <h5>${fields.price/100}</h5>
        </article>
        )
    })
}

However, the error I get is "Property 'map' does not exist on type 'ProductsArrayInterface'". I tried using products.products.map() instead, and while that quieted the compiler errors, on run time the page doesn't load and it gives the "cannot read properties of undefined (reading 'map')" error in the console. So I am not sure what to do. What should I be doing here to render the array of objects?

🌐
Tim Mousk
timmousk.com › blog › react-loop-through-array-of-objects
How To Loop Through An Array Of Objects In React? – Tim Mouskhelichvili
March 11, 2023 - The first method to loop through an array of objects involves using the JavaScript map function with a callback that returns the React component.
🌐
GitConnected
levelup.gitconnected.com › lets-loop-data-inside-a-react-component-832e9130ed0f
React loop through an array of objects and inside a object | Level Up Coding
November 29, 2021 - we can use the .map to loop through the array and access each object element using template literals {}
🌐
Sentry
sentry.io › sentry answers › react › how do you loop inside react jsx?
How do you loop inside React JSX? | Sentry
import React from "react"; function ... <ul>{seasonsList}</ul> </div> ); } export default App; You can use the map() method on an array to loop through the elements and create components, or generate JSX, inside the return ...
🌐
DhiWise
dhiwise.com › post › mastering-react-iterate-over-object-a-comprehensive-guide
Mastering React Iterate Over Object: A Comprehensive Guide
September 5, 2024 - This pattern is directly applicable to React when rendering lists of components based on an array of data. Looping through objects in React requires converting the object into an iterable format, such as an array of keys, values, or entries.
🌐
Thinkster
thinkster.io › tutorials › iterating-and-rendering-loops-in-react
Iterating & Rendering with Loops in React components - Thinkster
For those of you who are Javascript experts, you’ll know that we can use Javascript’s map method to quickly iterate over our array and create a new one with our desired values! Not so fast though — also remember that <li>Jake</li> actually boils down to React.createElement('li', null, ‘Jake’), so our elements are actually just methods that will be executed.
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-to-render-an-array-of-objects-in-reactjs
How To Render An Array Of Objects In ReactJS? - GeeksforGeeks
July 23, 2025 - The most common and recommended way to render an array of objects in React is by using the Array.map method to iterate through the array.
🌐
Altcademy
altcademy.com › blog › how-to-loop-through-an-array-in-reactjs
How to loop through an array in ReactJS - Altcademy.com
November 9, 2023 - This is essentially what looping does. It allows us to go through each element in an array, perform some computation, and move to the next one. In ReactJS, we often need to display lists or collections on the user interface.
🌐
SheCodes
shecodes.io › athena › 10518-how-to-loop-an-array-in-react-and-render-the-results
[React] - How to Loop an Array in React and Render the | SheCodes
Learn how to loop through an array in React and render it on the page, including a key for each element, using the .map() function. ... I am currently handling a search form in React.
🌐
GUVI
guvi.in › blog › programming languages › how to render an array of objects in react? [in 3 easy steps]
How to Render an Array of Objects in React? [in 3 easy steps]
October 21, 2025 - To render an array of objects/items in React, we loop through the array using the .map() method and return a single item.