I’m developing a react app, I want to try some functions in my mobile but when I try to connect to it, I have an error.
I understand that is an asynchronus problem… I’m trying to map an (by the moment) undefined array. But I don’t understand by in the browser is working well and in my mobile not.
const eventsFetch = async () => {
const resEvents = await getAllEvents();
const newArray = resEvents.filter((e) => {
const date = new Date(e.date);
return date.getTime() >= Date.now();
});
newArray.sort((e) => e.important === true ? -1 : 1);
setEvents(newArray);
}
Here is an screenshot from the mobile browser.. I tried with Chrome, Safari and Brave and always I got the same error.
By last, I already try adding the optional chaining operator to the array, but I have the same result.