react-tree-list icon indicating copy to clipboard operation
react-tree-list copied to clipboard

Implement "allowChildren" parameter on data

Open bartaxyz opened this issue 5 years ago • 0 comments

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

bartaxyz avatar Aug 20 '20 14:08 bartaxyz