Skip to content

Commit 2adde5e

Browse files
techievivekOSBotify
authored andcommitted
Merge pull request #37261 from dukenv0307/fix/37253-console-error-show-up
Fix/37253: Console log error when opening thread (cherry picked from commit a13a69d)
1 parent caf5adf commit 2adde5e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/components/FlatList/MVCPFlatList.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const MVCPFlatList = React.forwardRef(({maintainVisibleContentPosition, horizont
3838
const firstVisibleViewRef = React.useRef(null);
3939
const mutationObserverRef = React.useRef(null);
4040
const lastScrollOffsetRef = React.useRef(0);
41+
const isListRenderedRef = React.useRef(false);
4142

4243
const getScrollOffset = React.useCallback(() => {
4344
if (scrollRef.current == null) {
@@ -137,6 +138,9 @@ const MVCPFlatList = React.forwardRef(({maintainVisibleContentPosition, horizont
137138
}, [adjustForMaintainVisibleContentPosition, getContentView, getScrollOffset, scrollToOffset]);
138139

139140
React.useEffect(() => {
141+
if (!isListRenderedRef.current) {
142+
return;
143+
}
140144
requestAnimationFrame(() => {
141145
prepareForMaintainVisibleContentPosition();
142146
setupMutationObserver();
@@ -186,6 +190,10 @@ const MVCPFlatList = React.forwardRef(({maintainVisibleContentPosition, horizont
186190
onScroll={onScrollInternal}
187191
scrollEventThrottle={1}
188192
ref={onRef}
193+
onLayout={(e) => {
194+
isListRenderedRef.current = true;
195+
props.onLayout?.(e);
196+
}}
189197
/>
190198
);
191199
});

0 commit comments

Comments
 (0)