Skip to content

How to pass and access custom properties in event object with Timeline inside TimelineList? #2714

@mraoxy

Description

@mraoxy

Hi,

I'm using TimelineList with custom rendering of events via the renderEvent prop of the Timeline component (passed through renderItem).

I would like to pass additional custom properties (e.g., location, user) to the event object, and access them in my custom UI inside renderEvent. However, it seems that the event object is typed as PackedEvent, which doesn't include any of my custom fields.

Here is a simplified version of my code:

<TimelineList
  events={eventsByDate}
  renderItem={(props: TimelineProps) => (
    <Timeline
      {...props}
      renderEvent={(event: PackedEvent) => (
        <View style={{ backgroundColor: event.color }}>
          <Text>{event.title}</Text>
          <Text>{event.location}</Text> {/* custom string field */}
          <Text>{event.user.name}</Text> {/* custom object field */}
        </View>
      )}
    />
  )}
/>

My questions
Is there an official way to pass and access custom fields on the event object inside renderEvent?

I noticed that PackedEvent only allows a limited set of fields. Is there another way to make renderEvent accept extended event data safely and cleanly?

Thanks a lot for the great library.

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