Fix Error in catalog (Encountered two children with the same key, -1.)

This commit is contained in:
DuckieTM 2024-03-16 09:34:39 +01:00
parent bfbc2109cd
commit 3e346f3ac6

View File

@ -71,18 +71,22 @@ export const CatalogView: FC<{}> = props =>
{ isVisible && { isVisible &&
<NitroCardView uniqueKey="catalog" className="nitro-catalog" style={ GetConfiguration('catalog.headers') ? { width: 710 } : {} }> <NitroCardView uniqueKey="catalog" className="nitro-catalog" style={ GetConfiguration('catalog.headers') ? { width: 710 } : {} }>
<NitroCardHeaderView headerText={ LocalizeText('catalog.title') } onCloseClick={ event => setIsVisible(false) } /> <NitroCardHeaderView headerText={ LocalizeText('catalog.title') } onCloseClick={ event => setIsVisible(false) } />
<NitroCardTabsView> <NitroCardTabsView subClassName="w-100">
{ rootNode && (rootNode.children.length > 0) && rootNode.children.map(child => {rootNode &&
{ rootNode.children.length > 0 &&
rootNode.children.map((child, index) => {
if (!child.isVisible) return null; if (!child.isVisible) return null;
// Generate a unique key using the index of the map function
const uniqueKey = `${child.pageId}-${index}`;
return ( return (
<NitroCardTabsItemView key={ child.pageId } isActive={ child.isActive } onClick={ event => <NitroCardTabsItemView
{ key={uniqueKey}
isActive={child.isActive}
onClick={(event) => {
if (searchResult) setSearchResult(null); if (searchResult) setSearchResult(null);
activateNode(child); activateNode(child);
} } > }}
>
<Flex gap={GetConfiguration('catalog.tab.icons') ? 1 : 0} alignItems="center"> <Flex gap={GetConfiguration('catalog.tab.icons') ? 1 : 0} alignItems="center">
{GetConfiguration('catalog.tab.icons') && <CatalogIconView icon={child.iconId} />} {GetConfiguration('catalog.tab.icons') && <CatalogIconView icon={child.iconId} />}
{child.localization} {child.localization}