Skip to content

Commit dec05c0

Browse files
committed
fix key warnings
1 parent 50ff26f commit dec05c0

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/client/packages/idom-client-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "idom-client-react",
33
"description": "A client for IDOM implemented in React",
4-
"version": "0.8.3",
4+
"version": "0.8.4",
55
"author": "Ryan Morshead",
66
"license": "MIT",
77
"type": "module",

src/client/packages/idom-client-react/src/component.js

+19-16
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,14 @@ export function Layout({ saveUpdateHook, sendEvent, loadImportSource }) {
2828
}
2929
}
3030

31-
export function Element({ model, key }) {
31+
export function Element({ model }) {
3232
if (model.importSource) {
3333
return html`<${ImportedElement} model=${model} />`;
3434
} else {
3535
return html`<${StandardElement} model=${model} />`;
3636
}
3737
}
3838

39-
export function elementChildren(modelChildren) {
40-
if (!modelChildren) {
41-
return [];
42-
} else {
43-
return modelChildren.map((child) => {
44-
switch (typeof child) {
45-
case "object":
46-
return html`<${Element} key=${child.key} model=${child} />`;
47-
case "string":
48-
return child;
49-
}
50-
});
51-
}
52-
}
53-
5439
function StandardElement({ model }) {
5540
const config = react.useContext(LayoutConfigContext);
5641
const children = elementChildren(model.children);
@@ -116,6 +101,24 @@ function ImportedElement({ model }) {
116101
}
117102
}
118103

104+
export function elementChildren(modelChildren) {
105+
if (!modelChildren) {
106+
return [];
107+
} else {
108+
return modelChildren.map((child, index) => {
109+
switch (typeof child) {
110+
case "object":
111+
return html`<${Element}
112+
key=${child.key || index.toString()}
113+
model=${child}
114+
/>`;
115+
case "string":
116+
return child;
117+
}
118+
});
119+
}
120+
}
121+
119122
function elementAttributes(model, sendEvent) {
120123
const attributes = Object.assign({}, model.attributes);
121124

0 commit comments

Comments
 (0)