Skip to content

Commit ae063f1

Browse files
authored
Add support for overriding existing implementation of ReservationList (#1969)
1 parent ec4a90b commit ae063f1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ An advanced `Agenda` component that can display interactive listings for calenda
557557
renderKnob={() => {
558558
return <View />;
559559
}}
560+
// Override inner list with a custom implemented component
561+
renderList={(listProps) => {
562+
return <MyCustomList {...listProps} />
563+
}}
560564
// Specify what should be rendered instead of ActivityIndicator
561565
renderEmptyData={() => {
562566
return <View />;

src/agenda/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isFunction from 'lodash/isFunction';
12
import PropTypes from 'prop-types';
23
import XDate from 'xdate';
34
import memoize from 'memoize-one';
@@ -43,6 +44,8 @@ export type AgendaProps = CalendarListProps & ReservationListProps & {
4344
onDayChange?: (data: DateData) => void;
4445
/** specify how agenda knob should look like */
4546
renderKnob?: () => JSX.Element;
47+
/** override inner list with a custom implemented component */
48+
renderList?: (listProps: ReservationListProps) => JSX.Element;
4649
/** initially selected day */
4750
selected?: string; //TODO: Should be renamed 'selectedDay' and inherited from ReservationList
4851
/** Hide knob button. Default = false */
@@ -79,6 +82,7 @@ export default class Agenda extends Component<AgendaProps, State> {
7982
onCalendarToggled: PropTypes.func,
8083
onDayChange: PropTypes.func,
8184
renderKnob: PropTypes.func,
85+
renderList: PropTypes.func,
8286
selected: PropTypes.any, //TODO: Should be renamed 'selectedDay' and inherited from ReservationList
8387
hideKnob: PropTypes.bool,
8488
showClosingKnob: PropTypes.bool
@@ -329,6 +333,14 @@ export default class Agenda extends Component<AgendaProps, State> {
329333

330334
renderReservations() {
331335
const reservationListProps = extractReservationListProps(this.props);
336+
if (isFunction(this.props.renderList)) {
337+
return this.props.renderList({
338+
...reservationListProps,
339+
selectedDay: this.state.selectedDay,
340+
topDay: this.state.topDay,
341+
onDayChange: this.onDayChange,
342+
});
343+
}
332344

333345
return (
334346
<ReservationList

0 commit comments

Comments
 (0)