Skip to content

Commit 0a340a3

Browse files
James Youngbloodmarkharding
authored andcommitted
[#105] Fix ThreadList loading on web
Changelog: fix
1 parent edc1d6a commit 0a340a3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • apps/polycentric/src/common/components

apps/polycentric/src/common/components/List.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function WebFeedViewer<T>({
122122
ListFooterComponent,
123123
ListEmptyComponent,
124124
onEndReached,
125+
onLoad,
125126
contentContainerStyle,
126127
stickyHeaderIndices,
127128
listRef,
@@ -141,6 +142,14 @@ function WebFeedViewer<T>({
141142
const items = (data as readonly T[] | null | undefined) ?? [];
142143
const [visibleCount, setVisibleCount] = useState(WEB_INITIAL_VISIBLE);
143144

145+
// Keep parity with native `FlashList` by calling `onLoad`.
146+
const hasFiredOnLoad = useRef(false);
147+
useEffect(() => {
148+
if (hasFiredOnLoad.current) return;
149+
hasFiredOnLoad.current = true;
150+
onLoad?.({ elapsedTimeInMs: 0 });
151+
}, [onLoad]);
152+
144153
// Reset window when the underlying list shrinks (refresh, identity
145154
// switch, etc.) so we don't keep stale slicing offsets.
146155
useEffect(() => {

0 commit comments

Comments
 (0)