javascriptreactjsfullcalendarrrule

How do I determine the instance date from clickevent callback in react FullCalendar for a recurring event?


We are using the FullCalendar react component and its RRule plugin and we specify recurring events as an rrule string. As such, a recurring calendar event is represented like this:

events: [
  {
    title: 'my recurring event',
    rrule: 'DTSTART:20120201T103000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20120601;BYDAY=MO,FR'
  }
]

FullCalendar expands the recurring event nicely into individual event instances with individual dates, and shows all the instances in the calendar view. When a user clicks on any one of the expanded instances, FullCalendar invokes our eventClick handler correctly and passes eventClickInfo (see https://fullcalendar.io/docs/eventClick).

However, the event object that is returned via the FullCalendar callback is the event with the rrule (shown above). How do I determine the instance date from clickevent? That is, is there a way to extract the instance date from the eventClickInfo object returned from FullCalndar? I need to know on which particular instance, i.e., the date of the specific instance on which the user clicked so I can then update it.

Thanks in advance


Solution

  • If you look at info.event.start in the event data provided by eventClick you will get the start date of the specific clicked event:

    eventClick: function (info) {
      console.log(info.event.start);
    }
    

    Working demo: https://codepen.io/ADyson82/pen/vYQbpQb