How to display a simple tree table? #80
Answered
by
rwieruch
xuanngo2001
asked this question in
Q&A
-
How to display a simple tree table? I was trying to display a tree table with the code below but I'm getting the following error at the line const tree = useTree(data);. I'm new to JS environment. Can someone help?
Here is the full code: import React from 'react';
import { CompactTable } from '@table-library/react-table-library/compact';
import { useTree } from '@table-library/react-table-library/tree';
// Reactjs v18
import { createRoot } from 'react-dom/client';
const rootContainer = document.getElementById('root');
const root = createRoot(rootContainer);
const list = [
{
id: "1",
name: "VSCode",
deadline: new Date(2020, 1, 17),
type: "SETUP",
isComplete: true,
},
{
id: "2",
name: "JavaScript",
deadline: new Date(2020, 2, 28),
type: "LEARN",
isComplete: true,
nodes: [
{
id: "2.1",
name: "Data Types",
deadline: new Date(2020, 2, 28),
type: "LEARN",
isComplete: true,
},
{
id: "2.2",
name: "Objects",
deadline: new Date(2020, 2, 28),
type: "LEARN",
isComplete: true,
},
],
},
];
const App = () => {
const data = { list };
const tree = useTree(data);
return (
<CompactTable data={data} tree={tree} />
);
};
// Reactjs v18
root.render(<App/>); |
Beta Was this translation helpful? Give feedback.
Answered by
rwieruch
Oct 17, 2022
Replies: 1 comment 4 replies
-
Try |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
xuanngo2001
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try
const data = { nodes: list };