Skip to content

Latest commit

 

History

History

react

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

npm version

Usage

DEMO

Install

yarn add @path-tree/react tslib

Basic Usage

import * as React from "react";
import * as ReactDOM from "react-dom";
import * as PathTree from "@path-tree/react";

const props: PathTree.Props = {
  pathItems: [
    {
      type: "file",
      path: "a/b/index.js",
    },
    {
      type: "file",
      path: "a/b/c/index.js",
    },
  ],
};

ReactDOM.render(<PathTree.Component {...props} />, document.querySelector("#root"));

Define components

import * as PathTree from "@path-tree/react";

const props: PathTree.Props = {
  FileComponent: (fileProps) => {
    return <p>{fileProps.path}</p>;
  },
  DirectoryComponent: (directoryProps) => {
    return <div>{directoryProps.children}</div>;
  },
  pathItems: [
    {
      type: "file",
      path: "a/b/index.js",
    },
    {
      type: "file",
      path: "a/b/c/index.js",
    },
  ],
};

LICENSE

@path-tree/react is MIT licensed.