diff --git a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/MinimalAppCard/index.tsx b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/MinimalAppCard/index.tsx index 709cee735748..8bffe698628d 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/MinimalAppCard/index.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/MinimalAppCard/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useCallback, useMemo } from "react"; import { TouchableOpacity } from "react-native"; import { Flex, Text } from "@ledgerhq/native-ui"; import AppIcon from "LLM/features/Web3Hub/components/AppIcon"; @@ -7,14 +7,19 @@ import { AppManifest } from "@ledgerhq/live-common/wallet-api/types"; export default function MinimalAppCard({ item, onPress, - disabled, }: { item: AppManifest; - onPress: () => void; - disabled?: boolean; + onPress: (manifest: AppManifest) => void; }) { + const disabled = useMemo(() => item.branch === "soon", [item]); + const handlePress = useCallback(() => { + if (!disabled) { + onPress(item); + } + }, [disabled, item, onPress]); + return ( - + {item.name} diff --git a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/index.tsx b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/index.tsx index 8ad1a8936088..fe2a658bc23f 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/index.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/HorizontalList/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from "react"; +import React from "react"; import { StyleSheet } from "react-native"; import { FlashList } from "@shopify/flash-list"; import { Box, Flex, InfiniteLoader, Text } from "@ledgerhq/native-ui"; @@ -10,36 +10,29 @@ type Props = { isLoading: boolean; data: AppManifest[]; onEndReached?: () => void; - extraData: (manifest: AppManifest) => void; + onPressItem: (manifest: AppManifest) => void; testID?: string; }; type PropRenderItem = { item: AppManifest; - extraData?: (manifest: AppManifest) => void; + onPressItem?: (manifest: AppManifest) => void; }; const identityFn = (item: AppManifest) => item.id; +const renderItem = ({ item, onPressItem = () => {} }: PropRenderItem) => { + return ; +}; + export default function HorizontalList({ title, isLoading, data, onEndReached, - extraData, + onPressItem, testID, }: Props) { - const renderItem = useCallback(({ item, extraData = () => {} }: PropRenderItem) => { - const disabled = item.branch === "soon"; - const handlePress = () => { - if (!disabled) { - extraData(item); - } - }; - - return ; - }, []); - return ( <> @@ -62,7 +55,7 @@ export default function HorizontalList({ estimatedItemSize={70} data={data} showsHorizontalScrollIndicator={false} - extraData={extraData} + extraData={onPressItem} onEndReached={onEndReached} /> diff --git a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/ManifestsCategoryList/index.tsx b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/ManifestsCategoryList/index.tsx index 7954f3033539..3ec4fd2d1ca7 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/ManifestsCategoryList/index.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubMain/components/ManifestsCategoryList/index.tsx @@ -34,7 +34,7 @@ const ManifestsCategoryList = ({ title, categoryId, navigation }: Props) => {