Skip to content

Commit

Permalink
fix: improve Tree component
Browse files Browse the repository at this point in the history
fix: #1668
  • Loading branch information
rgah2107 committed Jun 30, 2020
1 parent 7abe1f6 commit 579b987
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/components/Tree/styled/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const Label = attachThemeAttrs(styled.h1)`
color: ${props => props.palette.text.main};
text-align: start;
line-height: 2;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
`;

export default Label;
20 changes: 12 additions & 8 deletions src/components/Tree/treeChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import React from 'react';
import Child from './child';

export default function TreeChildren({ data, onSelect, onExpandCollapse, nodePath }) {
return data.map((props, index) => (
<Child
{...props}
onSelect={onSelect}
onExpandCollapse={onExpandCollapse}
nodePath={[...nodePath, index]}
/>
));
return data.map((props, index) => {
const key = `child-item-${index}`;
return (
<Child
{...props}
key={key}
onSelect={onSelect}
onExpandCollapse={onExpandCollapse}
nodePath={[...nodePath, index]}
/>
);
});
}

0 comments on commit 579b987

Please sign in to comment.