|
1 | 1 | import { Moment } from "moment/moment"; |
2 | | -import React, { FC } from "react"; |
| 2 | +import React, { FC, useCallback } from "react"; |
3 | 3 | import { useTranslation } from "react-i18next"; |
4 | 4 | import { StyleSheet, View, ViewStyle } from "react-native"; |
5 | 5 | import { TouchableOpacity } from "react-native-gesture-handler"; |
@@ -58,13 +58,11 @@ export const DealerCard: FC<DealerCardProps> = ({ containerStyle, style, dealer, |
58 | 58 | const stylePre = useThemeBackground(present ? "primary" : "darken"); |
59 | 59 | const avatarBackground = useThemeBackground("primary"); |
60 | 60 |
|
| 61 | + const onPressBind = useCallback(() => onPress?.(dealer.details), [dealer.details, onPress]); |
| 62 | + const onLongPressBind = useCallback(() => onLongPress?.(dealer.details), [dealer.details, onLongPress]); |
| 63 | + |
61 | 64 | return ( |
62 | | - <TouchableOpacity |
63 | | - containerStyle={containerStyle} |
64 | | - style={[styles.container, appStyles.shadow, styleBackground, style]} |
65 | | - onPress={() => onPress?.(dealer.details)} |
66 | | - onLongPress={() => onLongPress?.(dealer.details)} |
67 | | - > |
| 65 | + <TouchableOpacity containerStyle={containerStyle} style={[styles.container, appStyles.shadow, styleBackground, style]} onPress={onPressBind} onLongPress={onLongPressBind}> |
68 | 66 | <View style={[styles.pre, stylePre]}> |
69 | 67 | <Image style={[avatarBackground, styles.avatarCircle]} source={avatar} contentFit="contain" placeholder={assetSource("ych")} transition={60} /> |
70 | 68 | </View> |
|
0 commit comments