fix(studio): Duplicate keys in NamespaceTree
This commit is contained in:
parent
9cf5c38aee
commit
e28a084dbb
1 changed files with 7 additions and 2 deletions
|
@ -40,10 +40,11 @@ function NamespaceTree(props: {
|
||||||
<>
|
<>
|
||||||
{[...props.namespace.entries()].map(([label, {object, nested}]) => {
|
{[...props.namespace.entries()].map(([label, {object, nested}]) => {
|
||||||
const children = (
|
const children = (
|
||||||
<>
|
<React.Fragment key={`${label} - ${props.visualIndentation}`}>
|
||||||
{object && (
|
{object && (
|
||||||
<ObjectItem
|
<ObjectItem
|
||||||
depth={props.visualIndentation}
|
depth={props.visualIndentation}
|
||||||
|
// key is useful for navigating react dev component tree
|
||||||
key={'objectPath(' + object.address.objectKey + ')'}
|
key={'objectPath(' + object.address.objectKey + ')'}
|
||||||
// object entries should not allow this to be undefined
|
// object entries should not allow this to be undefined
|
||||||
sheetObject={object}
|
sheetObject={object}
|
||||||
|
@ -53,16 +54,20 @@ function NamespaceTree(props: {
|
||||||
{nested && (
|
{nested && (
|
||||||
<NamespaceTree
|
<NamespaceTree
|
||||||
namespace={nested}
|
namespace={nested}
|
||||||
|
// Question: will there be key conflict if two components have the same labels?
|
||||||
|
key={'namespaceTree(' + label + ')'}
|
||||||
visualIndentation={props.visualIndentation + 1}
|
visualIndentation={props.visualIndentation + 1}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
|
|
||||||
return nested ? (
|
return nested ? (
|
||||||
<BaseItem
|
<BaseItem
|
||||||
selectionStatus="not-selectable"
|
selectionStatus="not-selectable"
|
||||||
label={label}
|
label={label}
|
||||||
|
// key necessary for no duplicate keys (next to other React.Fragments)
|
||||||
|
key={`baseItem(${label})`}
|
||||||
depth={props.visualIndentation}
|
depth={props.visualIndentation}
|
||||||
children={children}
|
children={children}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue