# @asany/tree

> React 排序树组件

Latest version **0.1.31** (published 2025-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @asany/tree
pnpm add @asany/tree
yarn add @asany/tree
bun add @asany/tree
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.31 |
| Published | 2025-01-02 |
| First published | 2021-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 290 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | 李茂峰 |
| Maintainers | limaofeng |

## Links

- npm: https://www.npmjs.com/package/@asany/tree
- Repository: https://github.com/limaofeng/asany-tree
- npm.io page: https://npm.io/package/@asany/tree

## Dependencies (2)

- [classnames](https://npm.io/package/classnames.md) ^2.3.1
- [@asany/sortable](https://npm.io/package/@asany/sortable.md) ^0.1.36

## Recent versions

- 0.1.31 (latest) — 2025-01-02
- 0.1.30 — 2025-01-02
- 0.1.29 — 2025-01-02
- 0.1.28 — 2022-07-07
- 0.1.27 — 2022-07-07
- 0.1.26 — 2022-07-04
- 0.1.25 — 2022-07-01
- 0.1.24 — 2022-07-01
- 0.1.23 — 2022-06-27
- 0.1.22 — 2022-06-23
- 0.1.21 — 2022-02-22
- 0.1.20 — 2022-02-22
- 0.1.19 — 2022-01-28
- 0.1.18 — 2022-01-28
- 0.1.17 — 2022-01-28
- … 15 more at https://npm.io/package/@asany/tree/versions

## README

# React Tree

React 排序树组件

## Install

```bash
npm i @asany/tree # or yarn add @asany/tree
```

## Usage

```tsx
const Example = () => {
  const [items, setItems] = useState([
    {
      key: '1',
      title: '荣耀',
      type: 'directory',
      children: [
        { key: '11', title: '鲁班7号', type: 'file' },
        { key: '12', title: '廉颇', type: 'file' },
        { key: '13', title: '凯', type: 'file' },
        {
          key: '14',
          title: '长城守卫军',
          type: 'directory',
          children: [{ key: '15', title: '苏烈', type: 'file' }],
        },
        { key: '121', title: '所得', type: 'file' },
      ],
    },
    { key: '2', title: '老王', type: 'file' },
    { key: '3', title: '老五', type: 'file' },
    { key: '4', title: '张三', type: 'file' },
    { key: '5', title: '赵六', type: 'file' },

    {
      key: '7',
      title: '王者营地',
      type: 'directory',
      children: [],
    },
  ]);

  const handleChange = (data, event) => {
    setItems(data);
  };
  return (
    <DndProvider backend={HTML5Backend}>
      <Tree treeData={items} />
    </DndProvider>
  );
};
```

## Maintainers

[@limaofeng](https://github.com/limaofeng).

## License

[MIT](LICENSE) © 李茂峰

---
_Source: https://npm.io/package/@asany/tree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
