Skip to content

Commit

Permalink
More readable?
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Jul 3, 2020
1 parent 3645d20 commit e120da9
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/material-ui-lab/src/TreeView/TreeView.js
Expand Up @@ -68,19 +68,15 @@ const TreeView = React.forwardRef(function TreeView(props, ref) {
state: 'selected',
});

const getChildrenIds = (id) => {
const childIds = [];

Object.keys(nodeMap.current).forEach((key) => {
const value = nodeMap.current[key];
if (value.parentId === id) {
childIds.splice(value.index, 0, value.id);
}
});

return childIds;
};

// Using Object.keys -> .map to mimic Object.values we should replace with Object.values() once we stop IE 11 support.
const getChildrenIds = (id) =>
Object.keys(nodeMap.current)
.map((key) => {
return nodeMap.current[key];
})
.filter((node) => node.parentId === id)
.sort((a, b) => a.index - b.index)
.map((child) => child.id);
/*
* Status Helpers
*/
Expand Down Expand Up @@ -401,7 +397,7 @@ const TreeView = React.forwardRef(function TreeView(props, ref) {
};

const handleMultipleSelect = (event, value) => {
let newSelected = [];
let newSelected;
if (selected.indexOf(value) !== -1) {
newSelected = selected.filter((id) => id !== value);
} else {
Expand Down

0 comments on commit e120da9

Please sign in to comment.