Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (data, parentSource) => {
// arrayToTree requires top level nodes to have their parent id set to null
const sanitizedData = data.map(item => ({
...item,
[parentSource]: item[parentSource] || null,
}));
return arrayToTree(sanitizedData, {
id: 'id',
parentId: parentSource,
})
.map(node => createNode(node))
.map(node => addParent(node, null));
};
render() {
const { ordered, blocks, setAttributes } = this.props
// Get headings list + define some needed datas
const headingsRaw = this.computeOutlineHeadings( blocks )
// Get parents Id in order to make a tree for nested ul/ol > li
const headingsFlat = this.compute( headingsRaw )
// Make the tree
const headings = arrayToTree( headingsFlat, { id: 'clientId', parentId: 'parentId' } )
return (
ordered && (
<ol>
</ol>
) || (
<ul>
</ul>
)
)
}
}
generateTreeFromFlatData = categories => arrayToTree(categories, {id: "id", parentId: "parent"});
generateTreeFromFlatData = categories => arrayToTree(categories, {id: "id", parentId: "parent"});
generateTreeFromFlatData = categories => arrayToTree(categories, {id: "id", parentId: "parent"});