fix(striker-ui): avoid always refreshing items in list by making key consistent

main
Tsu-ba-me 11 months ago
parent 1713ea4de7
commit cc10eab7f3
  1. 19
      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<Theme> | undefined = useMemo(
() => (isScroll ? { maxHeight: '100%', overflowY: 'scroll' } : undefined),

Loading…
Cancel
Save