const list2tree = (list,parentId)=>{
let obj = {}
list.forEach(item=>{
item.children=[]
obj[item.id]=item
})
return list.filter(item=>{
if(item.parentId !== parentId){
obj[item.parentId].children.push(item)
return false;
}
return true
})
}
Comments | NOTHING