Skip to content

Commit 4ace1b6

Browse files
JCourt1Bob Fanger
authored andcommitted
fix: children with the same key warning
Bridge and Hook components were being created with the same key as children of the same parent
1 parent fae87ed commit 4ace1b6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"type": "git",
1111
"url": "https://github.com/bfanger/svelte-preprocess-react.git"
1212
},
13-
"version": "0.13.0",
13+
"version": "0.14.0",
1414
"license": "MIT",
1515
"type": "module",
1616
"scripts": {

src/lib/internal/Bridge.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Bridge: React.FC<BridgeProps> = ({ createPortal, node }) => {
2323
}
2424
const children: React.ReactElement[] = node.nodes.map((subnode) => {
2525
return React.createElement(Bridge, {
26-
key: subnode.key,
26+
key: `bridge${subnode.key}`,
2727
createPortal,
2828
node: subnode,
2929
});
@@ -38,7 +38,9 @@ const Bridge: React.FC<BridgeProps> = ({ createPortal, node }) => {
3838
}
3939
if (hooks.length >= 0) {
4040
children.push(
41-
...hooks.map(({ Hook, key }) => React.createElement(Hook, { key }))
41+
...hooks.map(({ Hook, key }) =>
42+
React.createElement(Hook, { key: `hook${key}` })
43+
)
4244
);
4345
}
4446
return createPortal(

0 commit comments

Comments
 (0)