File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed
src/agenda/reservation-list Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export type ReservationListProps = ReservationProps & {
3939} ;
4040interface State {
4141 reservations : DayAgenda [ ] ;
42+ version : number ;
4243}
4344declare class ReservationList extends Component < ReservationListProps , State > {
4445 static displayName : string ;
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ class ReservationList extends Component {
4141 super ( props ) ;
4242 this . style = styleConstructor ( props . theme ) ;
4343 this . state = {
44- reservations : [ ]
44+ reservations : [ ] ,
45+ version : 0
4546 } ;
4647 this . heights = [ ] ;
4748 this . selectedDay = props . selectedDay ;
@@ -61,8 +62,11 @@ class ReservationList extends Component {
6162 }
6263 }
6364 updateDataSource ( reservations ) {
64- console . log ( 'updating data source' ) ;
65- this . setState ( { reservations } ) ;
65+ this . setState ( prev => ( {
66+ ...prev ,
67+ reservations,
68+ version : prev . version + 1
69+ } ) ) ;
6670 }
6771 updateReservations ( props ) {
6872 const { selectedDay, showOnlySelectedDayItems } = props ;
@@ -191,7 +195,7 @@ class ReservationList extends Component {
191195 }
192196 return < ActivityIndicator style = { this . style . indicator } color = { theme ?. indicatorColor } /> ;
193197 }
194- return ( < FlatList ref = { this . list } style = { style } contentContainerStyle = { this . style . content } data = { this . state . reservations } renderItem = { this . renderRow } keyExtractor = { this . keyExtractor } showsVerticalScrollIndicator = { false } scrollEventThrottle = { 200 } onMoveShouldSetResponderCapture = { this . onMoveShouldSetResponderCapture } onScroll = { this . onScroll } refreshControl = { this . props . refreshControl } refreshing = { this . props . refreshing } onRefresh = { this . props . onRefresh } onScrollBeginDrag = { this . props . onScrollBeginDrag } onScrollEndDrag = { this . props . onScrollEndDrag } onMomentumScrollBegin = { this . props . onMomentumScrollBegin } onMomentumScrollEnd = { this . props . onMomentumScrollEnd } /> ) ;
198+ return ( < FlatList ref = { this . list } style = { style } contentContainerStyle = { this . style . content } data = { this . state . reservations } renderItem = { this . renderRow } keyExtractor = { this . keyExtractor } extraData = { this . state . version } showsVerticalScrollIndicator = { false } scrollEventThrottle = { 200 } onMoveShouldSetResponderCapture = { this . onMoveShouldSetResponderCapture } onScroll = { this . onScroll } refreshControl = { this . props . refreshControl } refreshing = { this . props . refreshing } onRefresh = { this . props . onRefresh } onScrollBeginDrag = { this . props . onScrollBeginDrag } onScrollEndDrag = { this . props . onScrollEndDrag } onMomentumScrollBegin = { this . props . onMomentumScrollBegin } onMomentumScrollEnd = { this . props . onMomentumScrollEnd } /> ) ;
195199 }
196200}
197201export default ReservationList ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export type ReservationListProps = ReservationProps & {
5959
6060interface State {
6161 reservations : DayAgenda [ ] ;
62+ version : number ;
6263}
6364
6465class ReservationList extends Component < ReservationListProps , State > {
@@ -102,7 +103,8 @@ class ReservationList extends Component<ReservationListProps, State> {
102103 this . style = styleConstructor ( props . theme ) ;
103104
104105 this . state = {
105- reservations : [ ]
106+ reservations : [ ] ,
107+ version : 0
106108 } ;
107109
108110 this . heights = [ ] ;
@@ -130,8 +132,11 @@ class ReservationList extends Component<ReservationListProps, State> {
130132 }
131133
132134 updateDataSource ( reservations : DayAgenda [ ] ) {
133- console . log ( 'updating data source' ) ;
134- this . setState ( { reservations} ) ;
135+ this . setState ( prev => ( {
136+ ...prev ,
137+ reservations,
138+ version : prev . version + 1
139+ } ) ) ;
135140 }
136141
137142 updateReservations ( props : ReservationListProps ) {
@@ -290,6 +295,7 @@ class ReservationList extends Component<ReservationListProps, State> {
290295 data = { this . state . reservations }
291296 renderItem = { this . renderRow }
292297 keyExtractor = { this . keyExtractor }
298+ extraData = { this . state . version }
293299 showsVerticalScrollIndicator = { false }
294300 scrollEventThrottle = { 200 }
295301 onMoveShouldSetResponderCapture = { this . onMoveShouldSetResponderCapture }
You can’t perform that action at this time.
0 commit comments