🌐
Syncfusion
syncfusion.com › react › tree grid
React TreeGrid | Lightning Fast Tree Table | Syncfusion
The React TreeGrid (tree table) is a high-performance component. It displays data in a hierarchical (tree-like) structure with a rich set of features.
Published   November 14, 2025
People also ask

Where can I find the Syncfusion React Tree Grid demo?
You can find our React TreeGrid demo, which demonstrates how to render and configure the TreeGrid.
🌐
syncfusion.com
syncfusion.com › react › tree grid
React TreeGrid | Lightning Fast Tree Table | Syncfusion
Why should you choose Syncfusion React Tree Grid?
The Syncfusion React Tree Grid provides the following features: · Load large amounts of data by dynamically loading child data on demand. · Include flexible UI interactions like expanding and collapsing parent records, dialog editing, and more. · Flexible data binding with support to use local and remote data sources such as JSON, RESTful services, OData services, and WCF services. · One of the best React Tree Grid in the market that offers feature-rich UI to interact with the software. · Attractive UI appearance with built-in themes such as fabric, bootstrap, etc. · Simple configuration and A
🌐
syncfusion.com
syncfusion.com › react › tree grid
React TreeGrid | Lightning Fast Tree Table | Syncfusion
How do I get started with Syncfusion React Tree Grid?
A good place to start would be our comprehensive getting started documentation.
🌐
syncfusion.com
syncfusion.com › react › tree grid
React TreeGrid | Lightning Fast Tree Table | Syncfusion
🌐
PrimeReact
primereact.org › treetable
PrimeReact | React UI Component Library
TreeTable is used to display hierarchical data in tabular format.
🌐
React Suite
rsuitejs.com › home › components › tree table
Tree Table - React Suite
Tree table is a table that displays hierarchical data in a tree structure. It is mainly used to display structured data.
🌐
CodeSandbox
codesandbox.io › examples › package › react-table-tree
react-table-tree examples - CodeSandbox
Use this online react-table-tree playground to view and fork react-table-tree example apps and templates on CodeSandbox.
🌐
StackBlitz
stackblitz.com › edit › react-tree-table-demo
React Tree Table Demo - StackBlitz
StackBlitz is the collaborative browser-based IDE for web developers. StackBlitz eliminates time-consuming local configuration and lets developers spend more time building.
🌐
npm
npmjs.com › package › cp-react-tree-table
cp-react-tree-table - npm
A fast, efficient tree table component for ReactJS.. Latest version: 1.1.2, last published: 2 years ago. Start using cp-react-tree-table in your project by running `npm i cp-react-tree-table`. There are 1 other projects in the npm registry using cp-react-tree-table.
      » npm install cp-react-tree-table
    
Published   Feb 18, 2024
Version   1.1.2
Author   Constantin Panaitescu
🌐
GitHub
github.com › constantin-p › cp-react-tree-table
GitHub - constantin-p/cp-react-tree-table: A fast, efficient tree table component for ReactJS.
A fast, efficient tree table component for ReactJS. - constantin-p/cp-react-tree-table
Starred by 97 users
Forked by 28 users
Languages   TypeScript 87.7% | JavaScript 12.3% | TypeScript 87.7% | JavaScript 12.3%
Find elsewhere
🌐
LogRocket
blog.logrocket.com › home › how to build a tree grid component in react
How to build a tree grid component in React - LogRocket Blog
June 4, 2024 - In this section, we’ll discuss some top React tree grid libraries and walk through their implementations. React Table is a lightweight node library that allows developers to create and represent data in a tabular form.
🌐
DevExtreme
js.devexpress.com › React › Demos › WidgetsGallery › Demo › TreeList › Overview
React Tree List - Overview | React Example
DevExtreme React Tree List is a UI component that displays hierarchical data in a table. Its main features include robust data layer, multiple editing modes, client-side data validation, numerous filtering and searching properties, and many more.
🌐
MUI
mui.com › x › react-tree-view
Tree View React component - MUI X
The Tree View components let users navigate hierarchical lists of data with nested levels that can be expanded and collapsed. ... This impressive paella is a perfect party dish and a fun meal to cook together with your guests.
🌐
Robin Wieruch
robinwieruch.de › react-tree-list
API Design for a React Tree Table
May 3, 2021 - In this tutorial, I want to show you how to use React Table Library to create a Tree Table or Tree List .
🌐
GitHub
github.com › JenniferFuBook › react-tree-table
GitHub - JenniferFuBook/react-tree-table: Exploring Tree Table Using Ant Design System
This project is based on Create React App. It explores the Tree Table using Ant Design System.
Author   JenniferFuBook
🌐
Material React Table
material-react-table.com › docs › examples › expanding tree
Expanding Tree Example - Material React Table V3 Docs
Material React Table supports showing rows in a expanding tree structure. This example is the simplest implementation of this feature where each row of data potentially has a special subRows property that contains an array of sub rows.
Top answer
1 of 2
1

In React, you must break your data into components. Working with the data as is, in multi-level nesting, is considered bad design - see here for a detailed explanation.

With this in mind, I dedicated one component for each nesting level. This way, the row can manage its sub-row hidden state. Here's the final code - see full demo here - click the "toggle" button:

index.js:

import React, { useState, useEffect } from "react";
import "./styles.css"

const Table = () => {
  const [items, setItems] = useState([]);

  useEffect(() => {
    fetchData();
  }, []);

  const fetchData = async () => {
    try {
      const response = await fetch("./data.json");
      const data = await response.json();
      setItems(data);
    } catch (e) {
      console.warn(e);
    }
  };
  
  return <div>
    {
      items.map((data) => { 
        return <TableData key={data.id} data={data} />
      })
    }
  </div>;
};

const TableData = (props) => {
  const data = props.data;
  const [subHidden, setSubHidden] = useState(false);
  
  const Id = (dataId) => {
    alert(dataId);
  };
  const Name = (dataName) => {
    alert(dataName);
  };
  const Toggle = () => {
    setSubHidden(state => { 
      return !state;
    });
  };

  return (
    <div >
      <span> {data.id} </span>
      <span> {data.name} </span>
      <span> {data.owner} </span>
      <span>
        <button onClick={() => Id(data.id)}>getId</button>
        <button onClick={() => Name(data.name)}>getname</button>
        <button onClick={() => Toggle()}>toggle</button>
      </span>
      <TableSubDetails 
        subDetails={data.sub_details}
        style={{ display: subHidden ? 'none' : 'block'}}
      />
    </div>
  );
}

const TableSubDetails = (props) => {
  const subDetails = props.subDetails;
  return (
    <div className="subData" style={props.style}>
      {
        subDetails.map((subData) => { 
          return <div key={subData.sub_id}>
            <span> {subData.sub_id} </span>
            <span> {subData.sub_name} </span>
          </div>
        })
      }
    </div>
  );
}

export default Table;

styles.css:

.subData {
  padding: 5px 15px;
}  
2 of 2
1

Here is my version of the solution by updating your existing code with some logic

const TableData = () => {
  const [oldData, newData] = useState([]);
  const [id, setId] = useState({});

  useEffect(() => {
    fetchData();
  }, []);

  const Id = (dataId) => {
    alert(dataId);
  };
  const Name = (dataName) => {
    alert(dataName);
  };

  const fetchData = async () => {
    try {
      newData(jsonData);
    } catch (e) {
      console.warn(e);
    }
  };

  const updateId = useCallback((dataId) => {
    setId((prevState) => {
      let updatedState = { ...prevState };
      const hasId = updatedState[dataId] ? true : false;

      if (hasId) {
        delete updatedState[dataId];
      } else {
        updatedState = { ...updatedState, [dataId]: dataId };
      }

      return {
        ...updatedState
      };
    });
  }, []);

  const renderTableRows = useCallback(
    (details, isChild = false) => {
      let renderData = [];

      details.forEach((detail) => {
        const detailId = isChild ? detail["sub_id"] : detail["id"];
        const name = isChild ? detail["sub_name"] : detail["name"];

        const childData = (
          <tr key={`${name}-${detailId}`}>
            <td> {detailId} </td>
            <td> {name} </td>
            <td> {detail.owner} </td>
            <td>
              <button onClick={() => Id(detailId)}>getId</button>
              <button onClick={() => Name(name)}>getname</button>
              {detail.sub_details?.length > 0 && (
                <button
                  onClick={() => {
                    updateId(detailId);
                  }}
                >
                  {id[detailId] === detailId ? "Hide" : "Show"} child
                </button>
              )}
            </td>
          </tr>
        );

        renderData.push(childData);

        if (id[detailId] === detailId && detail.sub_details?.length > 0) {
          const childData = renderTableRows(detail.sub_details, true);
          renderData = [...renderData, ...childData];
        }
      });

      return renderData;
    },
    [id, updateId]
  );

  const DisplayData = useMemo(() => {
    return renderTableRows(oldData);
  }, [oldData, renderTableRows]);

  return (
    <div>
      <div>
        <table>
          <thead>
            <tr>
              <th>id</th>
              <th>name</th>
              <th>owner</th>
            </tr>
          </thead>
          <tbody> {DisplayData} </tbody>
        </table>
      </div>
    </div>
  );
};

export default TableData;

here is the example link.

Thanks

🌐
Ant Design
ant.design › components › tree
Tree - Ant Design
Examples include directories, organization hierarchies, biological classifications, countries, etc. The Tree component is a way of representing the hierarchical relationship between these things.
🌐
MUI X
mui.com › x › react-data-grid › tree-data
Data Grid - Tree data - MUI X
Use tree data to render rows with parent-child relationships in the Data Grid.
🌐
Svar
docs.svar.dev › guides › configuration › creating the table tree
Creating the table tree | React Grid Documentation
import { Grid } from "@svar-ui/react-grid"; const treeColumns = [ { id: "id", width: 80 }, { id: "lastName", header: "Last Name", flexgrow: 1, treetoggle: true, }, { id: "firstName", header: "First Name" }, { id: "city", width: 100, header: "City" }, ]; const treeData = [ { id: 1, city: "Amieshire", firstName: "Ernest", lastName: "Schuppe", open: false, data: [ { id: "1.1", city: "Gust", firstName: "Janis", lastName: "Vandervort", }, { id: "1.2", city: "Amieshire", firstName: "Makenzie", lastName: "Bode", }, ], }, { id: 2, city: "Amieshire", firstName: "Ciara", lastName: "Towne", data: [ { id: "2.1", city: "Amieshire", firstName: "Suzanne", lastName: "Wolff", }, { id: "2.2", city: "Amieshire", firstName: "Alessandra", lastName: "Feeney", }, ], }, ]; export default function TreeExample() { return <Grid tree={true} data={treeData} columns={treeColumns} />; }
🌐
AG Grid
ag-grid.com › react-data-grid › tree-data
React Grid: Tree Data - Overview | AG Grid
Tree Data provides a way to supply the grid with structured hierarchical data. Download AG Grid v35.1.0 today: The best React Table & React Data Grid in the world.
🌐
React
react.dev › learn › rendering-lists
Rendering Lists – React
Keys tell React which array item ... get deleted. A well-chosen key helps React infer what exactly has happened, and make the correct updates to the DOM tree....