npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react.js-nested-tree

v1.2.1

Published

The react.js-nested-tree package is a versatile React component designed for creating nested, hierarchical tree structures. This package is especially useful for applications that require a visual representation of nested data, such as file explorers, cat

Downloads

15

Readme

react.js-nested-tree

imageTree

Description:

The react.js-nested-tree package is a versatile React component designed for creating nested, hierarchical tree structures. This package is especially useful for applications that require a visual representation of nested data, such as file explorers, category trees, or organizational charts.

Installation:

npm install react.js-nested-tree
# or
yarn add react.js-nested-tree

Key Features:

  • Declarative Approach: Allows developers to define tree structures using a simple and intuitive JSON format.
  • Dynamic Data Handling: Supports dynamic loading of tree nodes, making it suitable for large datasets or data fetched from remote sources.
  • Customizable Appearance: Provides options for customizing the appearance and behavior of tree nodes, including icons, styles, and animations.
  • Interactivity: Supports interactive features such as node selection, expansion, and collapse, making it user-friendly and interactive.
  • Performance Optimization: Designed with performance in mind, ensuring smooth operation even with complex and deeply nested structures.

Usage:

Props

The TreeProps interface defines the properties for the Tree component. Below is a detailed description of each property.

| Property | Type | Description | | ------------------ | ------------------------------- | ------------------------------------------------------------------------ | | treeData | Item[] | An array of Item objects representing the data for the tree structure. | | treeClassName | string | (Optional) A class name to apply to the tree container element. | | itemClassName | string | (Optional) A class name to apply to each tree item. | | subTreeClassName | string | (Optional) A class name to apply to each sub-tree container. | | ItemComponent | React.ComponentType<TreeItem> | A React component to render each tree item. | | subTreeStyle | React.CSSProperties | (Optional) Inline styles to apply to each sub-tree container. | | parentTreeStyle | React.CSSProperties | (Optional) Inline styles to apply to the parent tree container. | | treeItemStyle | React.CSSProperties | (Optional) Inline styles to apply to each tree item. |

Example

  • ./App.tsx
import "./App.css";
import { TreeItems } from "./TreeItems";
import { Tree } from "react.js-nested-tree";
function App() {
  const treeData = [
    {
      id: 1,
      name: "Root Node",
      children: [
        {
          id: 2,
          name: "Child Node 1",
          children: [
            { id: 3, name: "Grandchild Node 1" },
            { id: 4, name: "Grandchild Node 2" },
          ],
        },
        { id: 5, name: "Child Node 2" },
      ],
    },
  ];
  return (
    <div>
      <Tree
        treeData={treeData}
        ItemComponent={TreeItems}
        parentTreeStyle={{ listStyleType: "none" }}
        treeItemStyle={{ listStyleType: "none" }}
      />
    </div>
  );
}

export default App;

API:

  • data: An array of objects representing the tree structure. Each object should have a unique id property. Optional children properties can be added for nested nodes.
  • Customization Options: Various props are available for customization, including node rendering functions, event handlers for node actions (e.g., onNodeClick, onNodeExpand), and styling options.

Conclusion:

The react.js-nested-tree package offers a robust solution for displaying hierarchical data in a React application. Its flexibility, ease of use, and performance optimizations make it an excellent choice for developers looking to implement nested tree structures with minimal hassle.

Demo

react-js-nested-tree-demo