react-sortable-tree-node
Version:
react-sortable-tree-node
71 lines (54 loc) • 1.59 kB
Markdown
# react-sortable-tree-node
> react-sortable-tree-node
[](https://www.npmjs.com/package/react-sortable-tree-node) [](https://standardjs.com)
## Install
```bash
npm install --save react-sortable-tree-node
```
## Demo
Demo and playground are available [here](https://bonnv79.github.io/react-sortable-tree-node/)
## Versions
[CHANGELOG](CHANGELOG.md)
## Usage Example
```JavaScript
import React from 'react';
import ReactSortableTreeNode from 'react-sortable-tree-node';
const data = [
{
id: 'item-0',
title: 'item 0',
dropDisabled: true,
dragDisabled: true
},
{
id: 'item-1',
title: ({ node, path, treeIndex }) => {
return `item 1 - treeIndex ${treeIndex}`
}
},
{
id: 'item-2',
title: 'item 2',
expanded: true,
isDirectory: true,
children: [
{
id: 'item-20',
title: 'item 20'
}
],
},
];
const [treeData, onChange] = React.useState(data);
<ReactSortableTreeNode treeData={treeData} onChange={onChange} />
```
## Develop
In the project directory, you can run:
### `npm install`
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:6006](http://localhost:6006) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
## License
MIT © [bonnv79](https://github.com/bonnv79)