react-native-calendars: Agenda loadItemsForMonth calls two time and gives wrong date

Description

Following are the issues in my app :-

  1. First time loadItemsForMonth calls twice.
  2. On scroll month loadItemsForMonth gives wrong date.
  3. On press date, loadItemsForMonth method call.

Expected Behavior

  1. First time loadItemsForMonth call only one time and it should return the exact date.
  2. On scroll month loadItemsForMonth return exact the date of visible month.
  3. On press date, calls only onDayPress not loadItemsForMonth.

My Code

<Agenda
        items={this.state.items}
        loadItemsForMonth={day => this.loadMonthData(day)}
        onDayPress={day => this.onDatePress(day)}
        renderItem={this.renderItem.bind(this)}
        renderEmptyDate={this.renderEmptyDate.bind(this)}
        rowHasChanged={this.rowHasChanged.bind(this)}
        refreshing={false}
        
/>

loadMonthData(day) {
    console.log("Month date :- ", day);
}

onDatePress(day) {
    console.log("On date press :- ", day);
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 20
  • Comments: 32 (1 by maintainers)

Most upvoted comments

So…I tried to debug the error myself. I don’t like messing in module code for risk it will break on updates, and I don’t understand the issue well enough to send a pull request, but when I add the prop

onVisibleMonthsChange={months => {
       console.log('now these months are visible', months);
}}

it shows that an additional month is being added the the “months” array. Then the onViewableItemsChanged is being called for some reason and setting the component state to months[0]. I changed the function to select months[1] and it appears to work well enough for now. I don’t know why this is happening, but if someone on the core team is going to fix the issue, I hope this will be a lead!

Another month, another person with this issue. How has everyone else worked around this?

still no solution?

Any solution to this ?

Any solution??