UNPKG

react-layouts-builder

Version:

Lightweight and powerfull react layouts drag and drop

28 lines (22 loc) 625 B
function removeLayout(layouts, id) { if (layouts.childrens) { for (var i = 0; i < layouts.childrens.length; i++) { var child = layouts.childrens[i]; var childID = child['@id'] || child.id; if (childID === id) { layouts.childrens.splice(i, 1); return layouts; } else if (child.childrens) { var removed = removeLayout(child, id); if (removed) { if (removed.childrens && removed.childrens.length === 0) { delete removed.childrens; } return layouts; } } } } return null; } export { removeLayout };