I'm new to react-native.I want to use array.map()
to render out some jsx in the UI.I'm looping over the API response which is as follows:
chosenProducts = [{id:1 , name:"carpet"} ,{id:24 , name:"toy"} ,{id:28 , name:"laser"} ,{id:137 , name:"map"} ,]
I use chosenProducts.map((prod)=>{some jsx})
to map over the array.but I want to add a key-value pair ex: order:1
to each product to be able to order them in the UI.
How can I dynamically add the order to them without changing the API response?
note: I'm using TypeScript
ps: I will use the order attribute to dynamically style the products. so it's not just the ordering!