Skip to content

Commit fa70446

Browse files
authored
AgendaList - fix sections update (#2022)
* AgendaList - wrap in forwardRef * remove ref wrapping * AgendaList - update `scrollToSection()` when 'sections' update * reorder imports
1 parent 3e18878 commit fa70446

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/expandableCalendar/agendaList.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import isUndefined from 'lodash/isUndefined';
77
import debounce from 'lodash/debounce';
88
import isEqual from 'lodash/isEqual';
99

10-
1110
import XDate from 'xdate';
1211

1312
import React, {useCallback, useContext, useEffect, useMemo, useRef} from 'react';
@@ -26,17 +25,16 @@ import {
2625
} from 'react-native';
2726

2827
import {useDidUpdate} from '../hooks';
29-
import {isToday, isGTE, sameDate} from '../dateutils';
3028
import {getMoment} from '../momentResolver';
29+
import {isToday, isGTE, sameDate} from '../dateutils';
3130
import {parseDate} from '../interface';
3231
import {getDefaultLocale} from '../services';
33-
import {UpdateSources, todayString} from './commons';
3432
import {Theme} from '../types';
35-
import styleConstructor from './style';
33+
import {UpdateSources, todayString} from './commons';
3634
import constants from '../commons/constants';
35+
import styleConstructor from './style';
3736
import Context from './Context';
3837

39-
4038
const viewabilityConfig = {
4139
itemVisiblePercentThreshold: 20 // 50 means if 50% of the item is visible
4240
};
@@ -183,7 +181,7 @@ const AgendaList = (props: AgendaListProps) => {
183181
viewOffset: (constants.isAndroid ? sectionHeight.current : 0) + viewOffset
184182
});
185183
}
186-
}, 1000, {leading: false, trailing: true}), []);
184+
}, 1000, {leading: false, trailing: true}), [viewOffset, sections]);
187185

188186
const _onViewableItemsChanged = useCallback((info: {viewableItems: Array<ViewToken>; changed: Array<ViewToken>}) => {
189187
if (info?.viewableItems && !sectionScroll.current) {
@@ -250,6 +248,7 @@ const AgendaList = (props: AgendaListProps) => {
250248

251249
return (
252250
<SectionList
251+
stickySectionHeadersEnabled
253252
{...props}
254253
ref={list}
255254
keyExtractor={_keyExtractor}
@@ -299,8 +298,3 @@ AgendaList.propTypes = {
299298
sectionStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
300299
avoidDateUpdates: PropTypes.bool
301300
};
302-
AgendaList.defaultProps = {
303-
dayFormat: 'dddd, MMM d',
304-
stickySectionHeadersEnabled: true,
305-
markToday: true
306-
};

0 commit comments

Comments
 (0)