Skip to content

AgendaList's renderSectionHeader has a string parameter instead of an object #2630

Open
@Wizzel1

Description

@Wizzel1
interface AgendaItem {
  title: string;
  data: {
    hour: string;
    duration: string;
    name: string;
    color?: string;
  }[];
}

const agendaItems: AgendaItem[] = [
  {
    title: '2025-03-20',
    data: [
      { hour: '09:00', duration: '1h', name: 'Team Meeting' },
      { hour: '14:30', duration: '45m', name: 'Dentist Appointment' },
    ],
  },
  {
    title: '2025-03-21',
    data: [
      { hour: '10:00', duration: '2h', name: 'Project Review' },
      { hour: '15:00', duration: '1h', name: 'Coffee with Client' },
    ],
  },
  {
    title: '2025-03-22',
    data: [{ hour: '11:00', duration: '1h', name: 'Gym Session' }],
  },
  {
    title: '2025-03-25',
    data: [
      { hour: '09:30', duration: '1h 30m', name: 'Strategy Planning' },
      { hour: '13:00', duration: '1h', name: 'Lunch with Team' },
      { hour: '16:00', duration: '2h', name: 'Code Review' },
    ],
  },
  {
    title: '2025-04-25',
    data: [
      { hour: '09:30', duration: '1h 30m', name: 'Strategy Planning' },
      { hour: '13:00', duration: '1h', name: 'Lunch with Team' },
      { hour: '16:00', duration: '2h', name: 'Code Review' },
    ],
  },
];

...

   <AgendaList
        sections={agendaItems}
        renderItem={renderItem}
        renderSectionHeader={(test) => {
          console.log(test); //test is a string here and has 2025-04-25 as content
          const localized = new Date(test as string).toLocaleDateString('en-US', {
            month: 'long',
            day: 'numeric',
            year: 'numeric',
          });
          return (
            <View style={{ backgroundColor: 'red', height: 50 }}>
              <Text style={{ color: 'white' }}>{localized}</Text>
            </View>
          );
        }}
        scrollToNextEvent
        dayFormat="yyyy-MM-d"
      />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions