Expo Calendar - Using the recurrenceRule for createEventAsync()

229 Views Asked by At

I'm struggling with some of the formatting for parameters inside the recurrenceRule when trying to create a new event with Expo Calendar. I can't seem to find any robust recurrence examples in the docs or anywhere else for that matter. One specific thing I'm struggling is daysOfTheWeek, where I'm trying to pass multiple days but I'm not even sure if you can.

Does anyone have a good working example of the recurrenceRule in action?

1

There are 1 best solutions below

0
Ian Matsumoto On

After struggling with this myself I found that if you look up types in your Calendar.d.ts file it should give you the required structure of the recurrenceRule.

export declare type RecurrenceRule = {
  frequency: string
  interval?: number // @default 1
  endDate?: string | Date
  occurrence?: number
  daysOfTheWeek?: DaysOfTheWeek[]
  daysOfTheMonth?: number[]
  monthsOfTheYear?: MonthOfTheYear[]
  weeksOfTheYear?: number[]
  daysOfTheYear?: number[]
  setPositions?: number[]
};

So if your use case is like mine and you just want the event to occur only once something like this will work: recurrenceRule: {frequency: 'DAILY', occurrence: 1} I think. Expo-documentation says recurrence rule can be set to null, but this throws an error. Hope this helps!