From 4ace1b646e90883626f5a5e76b4479ef070098c8 Mon Sep 17 00:00:00 2001 From: joseph Date: Fri, 9 Dec 2022 13:25:17 +0100 Subject: [PATCH] fix: children with the same key warning Bridge and Hook components were being created with the same key as children of the same parent --- package.json | 2 +- src/lib/internal/Bridge.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2acee11..912a31d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "type": "git", "url": "https://github.com/bfanger/svelte-preprocess-react.git" }, - "version": "0.13.0", + "version": "0.14.0", "license": "MIT", "type": "module", "scripts": { diff --git a/src/lib/internal/Bridge.ts b/src/lib/internal/Bridge.ts index ad76022..5907d67 100644 --- a/src/lib/internal/Bridge.ts +++ b/src/lib/internal/Bridge.ts @@ -23,7 +23,7 @@ const Bridge: React.FC = ({ createPortal, node }) => { } const children: React.ReactElement[] = node.nodes.map((subnode) => { return React.createElement(Bridge, { - key: subnode.key, + key: `bridge${subnode.key}`, createPortal, node: subnode, }); @@ -38,7 +38,9 @@ const Bridge: React.FC = ({ createPortal, node }) => { } if (hooks.length >= 0) { children.push( - ...hooks.map(({ Hook, key }) => React.createElement(Hook, { key })) + ...hooks.map(({ Hook, key }) => + React.createElement(Hook, { key: `hook${key}` }) + ) ); } return createPortal(