@@ -44,6 +44,8 @@ export type ReservationListProps = ReservationProps & {
4444 refreshing ?: boolean ;
4545 /** If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly */
4646 onRefresh ?: ( ) => void ;
47+ /** Extractor for underlying FlatList. Ensure that this is unique per item, or else scrolling may have duplicated and / or missing items. */
48+ keyExtractor ?: ( item : DayAgenda , index : number ) => string ;
4749} ;
4850
4951interface DayAgenda {
@@ -75,7 +77,8 @@ class ReservationList extends Component<ReservationListProps, State> {
7577 onMomentumScrollEnd : PropTypes . func ,
7678 refreshControl : PropTypes . element ,
7779 refreshing : PropTypes . bool ,
78- onRefresh : PropTypes . func
80+ onRefresh : PropTypes . func ,
81+ keyExtractor : PropTypes . func
7982 } ;
8083
8184 static defaultProps = {
@@ -258,7 +261,9 @@ class ReservationList extends Component<ReservationListProps, State> {
258261 ) ;
259262 } ;
260263
261- keyExtractor = ( _item : DayAgenda , index : number ) => String ( index ) ;
264+ keyExtractor = ( item : DayAgenda , index : number ) => {
265+ return this . props . keyExtractor ?.( item , index ) || `${ item ?. reservation ?. day } ${ index } ` ;
266+ }
262267
263268 render ( ) {
264269 const { items, selectedDay, theme, style} = this . props ;
0 commit comments