I'm trying to map an array but I think it filled wrong because it gives undefined
for the things I added a few things but they come up as undefined
for some reasons
if you look at the top its sort of an separate array in the top and the rest will be undefined
if I try to get them with .map()
this picture is from a console log here:
{RuuviTag.map((tag) => (
<div key={tag.MAC}>
{console.log(tag.MAC),
console.log(tag)
}
<Marker position={[tag.Latitude.replace(/,/g, '.'), tag.Longitude.replace(/,/g, '.')]} icon={new Icon({
iconUrl: tag.colorIcon,
iconSize: [25, 41],
iconAnchor: [12, 41] })} >
<Popup>
<h1>{tag.MAC}
</h1>
<h1>
</h1>
</Popup>
</Marker>
</div>
))}\
this is the code where I fill the array:
async function getData() {
setLoading(true);
ref.onSnapshot((querySnapshot) => {
let items = [];
querySnapshot.forEach((doc) => {
let item = doc.data()
console.log(doc.data().RawData)
PostRawData(doc.data().RawData).then(function (result) {
console.log(result)
item.decryptedData = result.data;
});
checkBoundaries(doc.data().RawData).then(function (result) {
console.log(result)
item.colorIcon = result;
});
console.log(item)
items.push(item);
console.log(items)
});
but when I try to map the colorIcon or something from the decrypted data it comeds up as undefined
Does anyone know how to fix this? I couldn't find this issue anywhere