diff options
author | dan <dan.abramov@gmail.com> | 2024-11-18 22:21:47 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-18 22:21:47 +0000 |
commit | 7b6c18272385494145676e42cbe922bde7ceae6b (patch) | |
tree | c8d41082b9a04e33e3b24b4d51e5af25cfd63daa /src/view/com/util/post-embeds/index.tsx | |
parent | 4f0f9eb4139a8c3439be0125ffd982b3cbf5c9b5 (diff) | |
download | voidsky-7b6c18272385494145676e42cbe922bde7ceae6b.tar.zst |
Add useHandleRef as a lighter alternative for useAnimatedRef (#6500)
Diffstat (limited to 'src/view/com/util/post-embeds/index.tsx')
-rw-r--r-- | src/view/com/util/post-embeds/index.tsx | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/view/com/util/post-embeds/index.tsx b/src/view/com/util/post-embeds/index.tsx index 1351a2cbc..9dc43da8e 100644 --- a/src/view/com/util/post-embeds/index.tsx +++ b/src/view/com/util/post-embeds/index.tsx @@ -6,13 +6,7 @@ import { View, ViewStyle, } from 'react-native' -import { - AnimatedRef, - measure, - MeasuredDimensions, - runOnJS, - runOnUI, -} from 'react-native-reanimated' +import {MeasuredDimensions, runOnJS, runOnUI} from 'react-native-reanimated' import {Image} from 'expo-image' import { AppBskyEmbedExternal, @@ -27,6 +21,7 @@ import { ModerationDecision, } from '@atproto/api' +import {HandleRef, measureHandle} from '#/lib/hooks/useHandleRef' import {usePalette} from '#/lib/hooks/usePalette' import {useLightboxControls} from '#/state/lightbox' import {useModerationOpts} from '#/state/preferences/moderation-opts' @@ -163,12 +158,13 @@ export function PostEmbeds({ } const onPress = ( index: number, - refs: AnimatedRef<React.Component<{}, {}, any>>[], + refs: HandleRef[], fetchedDims: (Dimensions | null)[], ) => { + const handles = refs.map(r => r.current) runOnUI(() => { 'worklet' - const rects = refs.map(ref => (ref ? measure(ref) : null)) + const rects = handles.map(measureHandle) runOnJS(_openLightbox)(index, rects, fetchedDims) })() } |