New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@o2xp/react-tree-view

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@o2xp/react-tree-view

@o2xp/react-tree-view

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
2
Created
Source

@o2xp/react-tree-view

codecov Maintainability Build License: MIT Version Style: prettier Linter: eslint (airbnb)

@o2xp/react-tree-view is a modulable component to build tree view and more !

See a show case just here.

Table of Contents

Getting Started

Installing

$ npm i --s @o2xp/react-tree-view

In your file :

// ES6
import React, { useState } from "react";
import TreeView from "@o2xp/react-tree-view";

const data = [
  {
    children: [
      {
        children: [
          {
            id: "file_1_1_1",
            label: "File 1-1-1"
          },
          {
            id: "file_1_1_2",
            label: "File 1-1-2"
          }
        ],
        id: "folder_1_1",
        label: "Folder 1-1"
      },
      {
        id: "folder_1_2",
        label: "Folder 1-2"
      }
    ],
    id: "folder_1",
    label: "Folder 1"
  },
  {
    children: [
      {
        id: "folder_2_1",
        label: "Folder 2-1"
      }
    ],
    id: "folder_2",
    label: "Folder 2"
  }
];

const App = () => {
  return (
    <div style={{ height: "100vh", width: "100%" }}>
      <TreeView data={data} />
    </div>
  );
};

export default App;

Live implementation

To go further check all examples

Prop Types

Data Property Required

data is an array compose of object with this structure.

PropertyTypeRequired?Description
idStringyesAn id that is uniq
labelStringyesLabel displayed
childrenArray<data>noAnd array of data type
anynoAny other data that you want in your node

Expanded Property Optional

expand is an array of string containing ids of data element which are expanded.

PropertyTypeRequired?Description
expandArray<String>yesArray of id

OnClick Property Optional

onClick is a function taking data node as parameter and returning nothing.

PropertyTypeRequired?Description
onClick(dataNode) => voidyesTriggered on data node click

OrderBy Property Optional

orderBy is and object compose of two array.

PropertyTypeRequired?Description
idsArray<String>yesArray composed of data node id
ordersArray<String>yesArray composed of value "asc" or "desc", see lodash documentation

ItemSize Property Optional

itemSize is the size of each element.

PropertyTypeRequired?Description
itemSizeNumberyesSize of element

Row Property Optional

Row is react component.

PropertyTypeRequired?Description
RowReact ComponentyesUsed to overwrite default row element

Contributing

Do you want to contribute to this project ? Great ! You can start by reading our contributing guide.

Build With

  • react - A JavaScript library for building user interfaces
  • rollup - Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application. It uses the standardized ES module format for code, instead of previous idiosyncratic solutions such as CommonJS and AMD.
  • memoize-one - A memoization library that only caches the result of the most recent arguments.
  • react-window - React window works by only rendering part of a large data set (just enough to fill the viewport). This helps address some common performance bottlenecks:

Contributors

Keywords

react

FAQs

Package last updated on 17 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts