Use useEffectEvent for effects with deliberately narrow deps (#11550)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tomasz Zawadzki
2026-09-07 12:18:08 +02:00
committed by GitHub
parent 8e52eba582
commit 52345ad3ca
5 changed files with 48 additions and 19 deletions
+10 -5
View File
@@ -1,4 +1,4 @@
import {useCallback, useEffect, useState} from 'react'
import {useCallback, useEffect, useEffectEvent, useState} from 'react'
import {type ListRenderItemInfo, View} from 'react-native'
import * as Contacts from 'expo-contacts/legacy'
import {type DidString} from '@atproto/syntax'
@@ -61,12 +61,17 @@ export function FindContactsSettingsScreen({}: Props) {
const {data, error, refetch} = useContactsSyncStatusQuery()
const isFocused = useIsFocused()
const logPresented = useEffectEvent(() => {
ax.metric('contacts:settings:presented', {
hasPreviouslySynced: !!data?.syncStatus,
matchCount: data?.syncStatus?.matchesCount,
})
})
useEffect(() => {
if (data && isFocused) {
ax.metric('contacts:settings:presented', {
hasPreviouslySynced: !!data.syncStatus,
matchCount: data.syncStatus?.matchesCount,
})
logPresented()
}
}, [data, isFocused])