@@ -18,14 +18,14 @@ export type ReservationListProps = ReservationProps & {
1818 the value of date key kas to be an empty array []. If there exists no value for date key it is
1919 considered that the date in question is not yet loaded */
2020 items ?: ReservationsType ;
21- selectedDay : XDate ;
22- topDay : XDate ;
21+ selectedDay ? : XDate ;
22+ topDay ? : XDate ;
2323 /** Show items only for the selected day. Default = false */
24- showOnlySelectedDayItems : boolean ;
24+ showOnlySelectedDayItems ? : boolean ;
2525 /** callback that gets called when day changes while scrolling agenda list */
2626 onDayChange ?: ( day : XDate ) => void ;
2727 /** specify what should be rendered instead of ActivityIndicator */
28- renderEmptyData : ( ) => JSX . Element ;
28+ renderEmptyData ? : ( ) => JSX . Element ;
2929 style ?: StyleProp < ViewStyle > ;
3030
3131 /** onScroll ListView event */
@@ -92,7 +92,7 @@ class ReservationList extends Component<ReservationListProps, State> {
9292 } ;
9393 private style : { [ key : string ] : ViewStyle | TextStyle } ;
9494 private heights : number [ ] ;
95- private selectedDay : XDate ;
95+ private selectedDay ? : XDate ;
9696 private scrollOver : boolean ;
9797 private list : React . RefObject < FlatList > = React . createRef ( ) ;
9898
@@ -116,7 +116,7 @@ class ReservationList extends Component<ReservationListProps, State> {
116116 }
117117
118118 componentDidUpdate ( prevProps : ReservationListProps ) {
119- if ( prevProps !== this . props ) {
119+ if ( this . props . topDay && prevProps . topDay && prevProps !== this . props ) {
120120 if ( ! sameDate ( prevProps . topDay , this . props . topDay ) ) {
121121 this . setState (
122122 {
@@ -139,6 +139,7 @@ class ReservationList extends Component<ReservationListProps, State> {
139139 updateReservations ( props : ReservationListProps ) {
140140 const { selectedDay} = props ;
141141 const reservations = this . getReservations ( props ) ;
142+ if ( selectedDay && this . selectedDay )
142143 if ( this . list && ! sameDate ( selectedDay , this . selectedDay ) ) {
143144 let scrollPosition = 0 ;
144145 for ( let i = 0 ; i < reservations . scrollPosition ; i ++ ) {
@@ -235,7 +236,7 @@ class ReservationList extends Component<ReservationListProps, State> {
235236 if ( ! row ) return ;
236237
237238 const day = row . day ;
238- const dateIsSame = sameDate ( day , this . selectedDay ) ;
239+ const dateIsSame = this . selectedDay && sameDate ( day , this . selectedDay ) ;
239240 if ( ! dateIsSame && this . scrollOver ) {
240241 this . selectedDay = day . clone ( ) ;
241242 this . props . onDayChange ?.( day . clone ( ) ) ;
@@ -269,7 +270,7 @@ class ReservationList extends Component<ReservationListProps, State> {
269270
270271 render ( ) {
271272 const { items, selectedDay, theme, style} = this . props ;
272- if ( ! items || ! items [ toMarkingFormat ( selectedDay ) ] ) {
273+ if ( ! items || selectedDay && ! items [ toMarkingFormat ( selectedDay ) ] ) {
273274 if ( isFunction ( this . props . renderEmptyData ) ) {
274275 return this . props . renderEmptyData ?.( ) ;
275276 }
0 commit comments