I had a javascript array that was rendering components using array.map
. I switched this array to an es6 Map
in order to be able to use key-value pairs
If you call .entries()
on your map you will get an iterator object which for every key/value pair contains an array with the structure: [key, value]
as mentioned here.
So you could just do:
{resultsByGuid.entries().map((result) => {
return this.renderGalleryItem(result[1], result[0]);
})}
I am still wondering, if there's a simpler solution though.