From fcdc1dd4864de37b8271cbd1fad40979df377014 Mon Sep 17 00:00:00 2001 From: Alex Benzer Date: Sun, 30 Nov 2025 15:48:35 -0800 Subject: [PATCH] Fix crash when clicking "find people to follow" --- src/components/ProgressGuide/FollowDialog.tsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/ProgressGuide/FollowDialog.tsx b/src/components/ProgressGuide/FollowDialog.tsx index 3316aa8615..428f75e7f2 100644 --- a/src/components/ProgressGuide/FollowDialog.tsx +++ b/src/components/ProgressGuide/FollowDialog.tsx @@ -3,7 +3,6 @@ import { TextInput, useWindowDimensions, View, - type ViewabilityConfig, type ViewToken, } from 'react-native' import {type ModerationOpts} from '@atproto/api' @@ -235,14 +234,17 @@ function DialogInner({guide}: {guide: Follow10ProgressGuide}) { // Track seen profiles const seenProfilesRef = useRef>(new Set()) - const onViewableItemsChanged = useCallback( + const itemsRef = useRef(items) + itemsRef.current = items + + const onViewableItemsChanged = useRef( ({viewableItems}: {viewableItems: ViewToken[]}) => { for (const viewableItem of viewableItems) { const item = viewableItem.item as Item if (item.type === 'profile') { if (!seenProfilesRef.current.has(item.profile.did)) { seenProfilesRef.current.add(item.profile.did) - const position = items.findIndex( + const position = itemsRef.current.findIndex( i => i.type === 'profile' && i.profile.did === item.profile.did, ) logger.metric( @@ -258,14 +260,10 @@ function DialogInner({guide}: {guide: Follow10ProgressGuide}) { } } }, - [items], - ) - const viewabilityConfig: ViewabilityConfig = useMemo( - () => ({ - itemVisiblePercentThreshold: 50, - }), - [], - ) + ).current + const viewabilityConfig = useRef({ + itemVisiblePercentThreshold: 50, + }).current const onSelectTab = useCallback( (interest: string) => {