mantinedev/mantine · error · Error

[@mantine/schedule] WeekView: Duplicated event ids found: ${

Error message

[@mantine/schedule] WeekView: Duplicated event ids found: ${event.id}

What it means

Thrown by filterWeekViewEvents in @mantine/schedule when two or more events in the events array share the same id. WeekView relies on ids for lookups, overlapping layout and React keys, so duplicates would produce incorrect week layout or rendering glitches. The library validates eagerly and fails fast instead of rendering wrong data.

Source

Thrown at packages/@mantine/schedule/src/components/WeekView/get-week-view-events/filter-week-view-events.ts:45

}: FilterWeekViewEventsInput): ScheduleEventData[] {
  if (events === undefined) {
    return [];
  }

  const ids = new Set<string | number>();
  const filteredEvents: ScheduleEventData[] = [];

  for (const event of events) {
    if (
      isWithinWeek({ event, targetWeek: date, firstDayOfWeek }) &&
      isEventInTimeRange({ event, startTime, endTime })
    ) {
      filteredEvents.push(validateEvent(event));

      if (!ids.has(event.id)) {
        ids.add(event.id);
      } else {
        throw new Error(`[@mantine/schedule] WeekView: Duplicated event ids found: ${event.id}`);
      }
    }
  }

  return filteredEvents;
}

View on GitHub (pinned to 8a284e2c2c)

Solutions

  1. De-duplicate events by id before rendering (keep the first or last occurrence)
  2. Fix the source of the duplicated id (generate ids with crypto.randomUUID() on creation)
  3. If events legitimately repeat, give each occurrence a unique id and link them via a shared groupId field

Example fix

// before
<WeekView events={[...workEvents, ...workEvents]} />

// after
const unique = Array.from(new Map(events.map((e) => [e.id, e])).values());
<WeekView events={unique} />
Defensive patterns

Strategy: validation

Validate before calling

const hasUniqueIds = (events: ScheduleEventData[]) =>
  new Set(events.map((e) => e.id)).size === events.length;

if (!hasUniqueIds(events)) {
  events = [...new Map(events.map((e) => [e.id, e])).values()];
}

Type guard

const hasUniqueEventIds = (events: ScheduleEventData[]): boolean =>
  new Set(events.map((e) => e.id)).size === events.length;

Prevention

When it happens

Trigger: Passing an events array to WeekView (or calling getWeekViewEvents) where two events have the same id value, e.g. merging event lists from two sources without de-duplicating, or re-adding an event after moving it between calendars.

Common situations: Concatenating events from multiple calendar feeds, copying an event and forgetting to regenerate its id, backend returning nested/repeated entries, or state-management bug appending the same event twice.

Related errors


AI-assisted analysis of mantinedev/mantine@8a284e2c2c (2026-08-28). Data as JSON: /api/errors/f958026f9204a7fc. Report an issue: GitHub.