react-tree-list
react-tree-list copied to clipboard
Implement "allowDropInside" on the data object
Defines whether content can be dropped inside an item. Children are still allowed, it's just impossible to drop any more children inside.
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 keep current children but prevent other items to be dropped inside
allowDropInside: true,
// Nodes inside "children" will be displayed and it will be possible to sort them, or drag them out
children: [
{ label: "Heyo", },
],
},
]);
return (
<ReactTreeList
data={data}
onChange={setData}
/>
);
};
Default: true