Get rid of visualizer "missing key" errors in browser console

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2025-10-06 11:32:59 +02:00
parent de09454468
commit 44061448f8
2 changed files with 9 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-app-visualizer': patch
---
Ensure that the text rendering has react keys for all elements
@@ -63,15 +63,15 @@ function nodeToText(
.filter(e => options?.showDisabled || e.instance)
.sort((a, b) => a.spec.id.localeCompare(b.spec.id));
if (children.length === 0) {
return mkDiv(`${key} []`, { indent: true });
return mkDiv(`${key} []`, { key, indent: true });
}
return mkDiv(
[
mkDiv(`${key} [`),
mkDiv(`${key} [`, { key: 'start' }),
...children.map(e =>
mkDiv(nodeToText(e, options), { indent: true }),
mkDiv(nodeToText(e, options), { indent: true, key: e.spec.id }),
),
mkDiv(']'),
mkDiv(']', { key: 'end' }),
],
{ key, indent: true },
);