From 77ecdf6b7bee047111ec1bac163daab8f5c24a24 Mon Sep 17 00:00:00 2001 From: duckietm Date: Thu, 20 Jul 2023 10:39:14 +0200 Subject: [PATCH] Small fix CatalogView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will fix: Warning: Encountered two children with the same key, -1. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version. --- src/components/catalog/CatalogView.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/catalog/CatalogView.tsx b/src/components/catalog/CatalogView.tsx index 6201c33a..a12499fa 100644 --- a/src/components/catalog/CatalogView.tsx +++ b/src/components/catalog/CatalogView.tsx @@ -72,12 +72,13 @@ export const CatalogView: FC<{}> = props => setIsVisible(false) } /> - { rootNode && (rootNode.children.length > 0) && rootNode.children.map(child => - { + { rootNode && rootNode.children.length > 0 && rootNode.children.map((child, index) => { if(!child.isVisible) return null; + // Generate a unique key using the index of the map function + const uniqueKey = `${child.pageId}-${index}`; return ( - + { { if(searchResult) setSearchResult(null);