Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Wizzel1 opened this issue Apr 1, 2025 · 0 comments

Comments

@Wizzel1
Copy link

Wizzel1 commented Apr 1, 2025

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"
      />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant