react-tree-list
react-tree-list copied to clipboard
Implement "allowChildren" parameter on data
This parameter defines whether children can or cannot be passed into the item. If false, this element also removes all current children. If you want to disallow only additional children but keep the current (keep them visible), use allowDropInside: false instead.
import React, { useState } from "react";
import { ReactTreeList, ReactTreeListProps } from '@bartaxyz/react-tree-list';
const Component: React.FC = () => {
const [data, setData] = useState<ReactTreeListProps["data"]>([
{
label: "none",
// This parameter will hide all children (not remove them from the object though)
allowChildren: true,
// Nodes inside "children" won't be displayed
children: [
{ label: "Heyo", },
],
},
]);
return (
<ReactTreeList
data={data}
onChange={setData}
/>
);
};
Default: true