Hi so I have this function that counts how many time a name appears in a list:
fire.firestore()
.collection("eventLikes")
.doc(eventID)
.onSnapshot((docSnapshot) => {
//}
// if(docSnapshot.data().ActivityLikes.length === 0) {
const nameCounts = docSnapshot.data().ActivityLikes.reduce((acc, cur) => {
acc[cur.name] = (acc[cur.name] || 0) + 1;
return acc;
}, {});
docSnapshot.data() is empty at the start and docSnapshot.data().ActivityLikes.length is sometimes empty so [] in firebase. But in NextJs i keep gettin this error:

How should i go about fixing this error?