@@ -25,6 +25,7 @@ import {
2525 TextProps
2626} from 'react-native' ;
2727
28+ import { useDidUpdate } from '../hooks' ;
2829import { isToday , isGTE , sameDate } from '../dateutils' ;
2930import { getMoment } from '../momentResolver' ;
3031import { parseDate } from '../interface' ;
@@ -88,7 +89,9 @@ const AgendaList = (props: AgendaListProps) => {
8889 markToday = true ,
8990 onViewableItemsChanged,
9091 } = props ;
92+
9193 const { date, updateSource, setDate, setDisabled} = useContext ( Context ) ;
94+
9295 const style = useRef ( styleConstructor ( theme ) ) ;
9396 const list = useRef < any > ( ) ;
9497 const _topSection = useRef ( sections [ 0 ] ?. title ) ;
@@ -104,7 +107,7 @@ const AgendaList = (props: AgendaListProps) => {
104107 }
105108 } , [ ] ) ;
106109
107- useEffect ( ( ) => {
110+ useDidUpdate ( ( ) => {
108111 // NOTE: on first init data should set first section to the current date!!!
109112 if ( updateSource !== UpdateSources . LIST_DRAG && updateSource !== UpdateSources . CALENDAR_INIT ) {
110113 scrollToSection ( date ) ;
@@ -194,14 +197,15 @@ const AgendaList = (props: AgendaListProps) => {
194197 }
195198 }
196199 onViewableItemsChanged ?.( info ) ;
197- } , [ _topSection . current , didScroll . current , avoidDateUpdates , setDate , onViewableItemsChanged ] ) ;
200+ } , [ avoidDateUpdates , setDate , onViewableItemsChanged ] ) ;
198201
199202 const _onScroll = useCallback ( ( event : NativeSyntheticEvent < NativeScrollEvent > ) => {
200203 if ( ! didScroll . current ) {
201204 didScroll . current = true ;
205+ scrollToSection . cancel ( ) ;
202206 }
203207 onScroll ?.( event ) ;
204- } , [ didScroll . current , onScroll ] ) ;
208+ } , [ onScroll ] ) ;
205209
206210 const _onMomentumScrollBegin = useCallback ( ( event : NativeSyntheticEvent < NativeScrollEvent > ) => {
207211 setDisabled ?.( true ) ;
0 commit comments