diff --git a/src/components/FlatList/index.tsx b/src/components/FlatList/index.tsx index 9f42e9597c79..f54eddcbeb79 100644 --- a/src/components/FlatList/index.tsx +++ b/src/components/FlatList/index.tsx @@ -44,6 +44,8 @@ function MVCPFlatList({maintainVisibleContentPosition, horizontal = false const mutationObserverRef = useRef(null); const lastScrollOffsetRef = useRef(0); const isListRenderedRef = useRef(false); + const mvcpAutoscrollToTopThresholdRef = useRef(mvcpAutoscrollToTopThreshold); + mvcpAutoscrollToTopThresholdRef.current = mvcpAutoscrollToTopThreshold; const getScrollOffset = useCallback((): number => { if (!scrollRef.current) { @@ -105,11 +107,11 @@ function MVCPFlatList({maintainVisibleContentPosition, horizontal = false const scrollOffset = getScrollOffset(); prevFirstVisibleOffsetRef.current = firstVisibleViewOffset; scrollToOffset(scrollOffset + delta, false); - if (mvcpAutoscrollToTopThreshold != null && scrollOffset <= mvcpAutoscrollToTopThreshold) { + if (mvcpAutoscrollToTopThresholdRef.current != null && scrollOffset <= mvcpAutoscrollToTopThresholdRef.current) { scrollToOffset(0, true); } } - }, [getScrollOffset, scrollToOffset, mvcpMinIndexForVisible, mvcpAutoscrollToTopThreshold, horizontal]); + }, [getScrollOffset, scrollToOffset, mvcpMinIndexForVisible, horizontal]); const setupMutationObserver = useCallback(() => { const contentView = getContentView();