Skip to content

Commit

Permalink
fix:add flatList key (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
linleiqin authored Sep 13, 2022
1 parent 482459b commit 0d73700
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/kit/src/views/Wallet/NFT/NFTList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
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';

import {
Box,
Empty,
FlatList,
useIsVerticalLayout,
useUserDevice,
} from '@onekeyhq/components';
Expand All @@ -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';
Expand Down Expand Up @@ -134,14 +127,18 @@ const NFTList: FC<NFTListProps> = ({
),
[onSelectAsset],
);

const flatListKey =
platformEnv.isNative && !platformEnv.isNativeIOSPad
? undefined
: `NFTList${numColumns}`;
const sharedProps = React.useMemo(
() => ({
contentContainerStyle: {
paddingLeft: 16,
paddingBottom: collectibles.length ? 16 : 0,
marginTop: 24,
},
key: flatListKey,
data: expand ? allAssets : collectibles,
renderItem: expand ? renderAssetItem : renderCollectionItem,
ListFooterComponent: <Box h="24px" w="full" />,
Expand Down Expand Up @@ -183,6 +180,7 @@ const NFTList: FC<NFTListProps> = ({
return `Collection ${index}`;
},
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[
collectibles,
expand,
Expand Down

0 comments on commit 0d73700

Please sign in to comment.