react-treeview-component

0.1.2 • Public • Published

React tree component

Tree component for react

Demo (Also check out the src/example/ folder for usage).

Install

npm install react-treeview-component

Include js file at "react-treeview-component/build/react-tree.js"
Include css file at "react-treeview-component/build/react-tree.css"

Usage

Added to your react component

<Treeview dataSource={this.props.dataSource}
  onTreenodeClick={this.handleTreenodeClick}>
</Treeview>

API

Properties

dataSouce

{
  "id": "string" // Unique identifier for the node
  "text": "string"  // Treenode display text
  "icon": "string" // Custom icon, CSS class
  "opened": Bool, // If the node is opened
  "selected": Bool, // If the node is selected
  "children": [] // Array of children nodes
}

onTreenodeClick

function (id, event)
  • id: node id
  • event: mouse clicked event

perform function on treenode clicked

Methods (Use though 'ref' property)

dfs

function (callback)
  • callback: 1 parameter: node

perform depth first search on dataSource, applying callback on each node

bfs

function (callback)
  • callback: 1 parameter: node

perform breadth first search on dataSource, applying callback on each node

License

MIT.

Package Sidebar

Install

npm i react-treeview-component

Weekly Downloads

8

Version

0.1.2

License

MIT

Last publish

Collaborators

  • yjcxy12