From cc10eab7f3b37433d91735d4fc2520ed777d8bf8 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Mon, 22 Jan 2024 17:15:29 -0500 Subject: [PATCH] fix(striker-ui): avoid always refreshing items in list by making key consistent --- striker-ui/components/List.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/striker-ui/components/List.tsx b/striker-ui/components/List.tsx index 825d33e5..b9059b32 100644 --- a/striker-ui/components/List.tsx +++ b/striker-ui/components/List.tsx @@ -14,7 +14,6 @@ import { Theme, } from '@mui/material'; import { FC, forwardRef, useCallback, useMemo } from 'react'; -import { v4 as uuidv4 } from 'uuid'; import { BLUE, BORDER_RADIUS, GREY, RED } from '../lib/consts/DEFAULT_THEME'; @@ -40,7 +39,7 @@ const List = forwardRef( insertHeader: isInsertHeader = true, listEmpty, listItemIconMinWidth = '56px', - listItemKeyPrefix = uuidv4(), + listItemKeyPrefix = 'list', listItemProps: { sx: listItemSx, ...restListItemProps } = {}, listItems, listProps: { sx: listSx, ...restListProps } = {}, @@ -226,18 +225,18 @@ const List = forwardRef( ); }); }, [ - loading, - listItems, + getListItemCheckboxProps, + isAllowItemButton, listEmptyElement, - renderListItem, - restListItemProps, + listItemCheckbox, listItemKeyPrefix, listItemSx, - listItemCheckbox, - renderListItemCheckboxState, - getListItemCheckboxProps, - isAllowItemButton, + listItems, + loading, onItemClick, + renderListItem, + renderListItemCheckboxState, + restListItemProps, ]); const listScrollSx: SxProps | undefined = useMemo( () => (isScroll ? { maxHeight: '100%', overflowY: 'scroll' } : undefined),