0.3.2 • Published 4 years ago

@path-tree/react v0.3.2

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

@path-tree/react

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.