'React-native-calendars agenda - problem with the renderItem function

I'm currently facing a pretty annoying issue with the react-native-calendars library, when using the Agenda component. This is the component:

 <Agenda
    items={agendaItems}
    selected={selectedDate}
    renderItem={renderItem}
    renderEmptyDate={renderEmptyDate}
    ref={agendaRef}

The problem occurs when I add a new element to "agendaItems". If I simply push to that array, everything is good, but once I try to sort the array and the order of elements change when a new item is added, then the renderItem function behaves very weird and on the UI I can see duplicates, even though the "agendaItems" has valid and correct data.

Please help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source