From 247b66f04ecb9b1e3d3df879a8e64211df040316 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Tue, 18 Mar 2025 16:18:51 -0500 Subject: [PATCH] Ensure unique keys for resource templates --- .../content/carousels/GenericCarousel.js | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/components/content/carousels/GenericCarousel.js b/src/components/content/carousels/GenericCarousel.js index 9234a8f..42da495 100644 --- a/src/components/content/carousels/GenericCarousel.js +++ b/src/components/content/carousels/GenericCarousel.js @@ -21,27 +21,48 @@ export default function GenericCarousel({items, selectedTopic, title}) { }); }, []); - const renderItem = (item) => { - if (!item) return ; + const generateUniqueTemplateKey = (item, index, type) => { + if (!item) return `${type}-${index}`; + const baseKey = item.id || item.d || `${type}-${index}`; + return `${type}-${baseKey}-${index}`; + }; + + const renderItem = (item, index) => { + if (!item) return ; if (item.topics?.includes('video') && item.topics?.includes('document')) { - return ; + return ; } else if (item.type === 'document') { - return ; + return ; } else if (item.type === 'video') { - return ; + return ; } else if (item.type === 'course') { - return ; + return ; } - return ; + return ; }; return (
{items.map((item, index) => ( -
- {renderItem(item)} +
+ {renderItem(item, index)}
))}