From 0d7370020642be65a550d98fc45bed6b3605ab2c Mon Sep 17 00:00:00 2001 From: linleiqin <278438611@qq.com> Date: Tue, 13 Sep 2022 22:53:38 +0800 Subject: [PATCH] fix:add flatList key (#1536) --- .../kit/src/views/Wallet/NFT/NFTList/index.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/kit/src/views/Wallet/NFT/NFTList/index.tsx b/packages/kit/src/views/Wallet/NFT/NFTList/index.tsx index 0ad93826b98..9084dee728b 100644 --- a/packages/kit/src/views/Wallet/NFT/NFTList/index.tsx +++ b/packages/kit/src/views/Wallet/NFT/NFTList/index.tsx @@ -1,11 +1,4 @@ -import React, { - ComponentProps, - FC, - useCallback, - useEffect, - useMemo, - useState, -} from 'react'; +import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { useNavigation } from '@react-navigation/native'; import { useIntl } from 'react-intl'; @@ -13,7 +6,6 @@ import { useIntl } from 'react-intl'; import { Box, Empty, - FlatList, useIsVerticalLayout, useUserDevice, } from '@onekeyhq/components'; @@ -32,6 +24,7 @@ import { ModalScreenProps, RootRoutes, } from '@onekeyhq/kit/src/routes/types'; +import platformEnv from '@onekeyhq/shared/src/platformEnv'; import backgroundApiProxy from '../../../../background/instance/backgroundApiProxy'; import { MAX_PAGE_CONTAINER_WIDTH } from '../../../../config'; @@ -134,7 +127,10 @@ const NFTList: FC = ({ ), [onSelectAsset], ); - + const flatListKey = + platformEnv.isNative && !platformEnv.isNativeIOSPad + ? undefined + : `NFTList${numColumns}`; const sharedProps = React.useMemo( () => ({ contentContainerStyle: { @@ -142,6 +138,7 @@ const NFTList: FC = ({ paddingBottom: collectibles.length ? 16 : 0, marginTop: 24, }, + key: flatListKey, data: expand ? allAssets : collectibles, renderItem: expand ? renderAssetItem : renderCollectionItem, ListFooterComponent: , @@ -183,6 +180,7 @@ const NFTList: FC = ({ return `Collection ${index}`; }, }), + // eslint-disable-next-line react-hooks/exhaustive-deps [ collectibles, expand,