Build a component that displays a hierarchical structure of checkboxes. The component should handle parent-child relationships between checkboxes and manage their states efficiently.
interface CheckboxItem {
id: number;
name: string;
checked: boolean | 'indeterminate';
children?: CheckboxItem[];
}
Example data:
const fileData = [
{
id: 1,
name: 'Electronics',
children: [
{
id: 2,
name: 'Mobile phones',
children: [
{
id: 3,
name: 'iPhone',
},
{
id: 4,
name: 'Android',
},
],
},
{
id: 5,
name: 'Laptops',
children: [
{
id: 6,
name: 'MacBook',
},
{
id: 7,
name: 'Surface Pro',
},
],
},
],
},
{
id: 8,
name: 'Books',
children: [
{
id: 9,
name: 'Fiction',
},
{
id: 10,
name: 'Non-fiction',
},
],
},
{
id: 11,
name: 'Toys',
},
];
Build a component that displays a hierarchical structure of checkboxes. The component should handle parent-child relationships between checkboxes and manage their states efficiently.
interface CheckboxItem {
id: number;
name: string;
checked: boolean | 'indeterminate';
children?: CheckboxItem[];
}
Example data:
const fileData = [
{
id: 1,
name: 'Electronics',
children: [
{
id: 2,
name: 'Mobile phones',
children: [
{
id: 3,
name: 'iPhone',
},
{
id: 4,
name: 'Android',
},
],
},
{
id: 5,
name: 'Laptops',
children: [
{
id: 6,
name: 'MacBook',
},
{
id: 7,
name: 'Surface Pro',
},
],
},
],
},
{
id: 8,
name: 'Books',
children: [
{
id: 9,
name: 'Fiction',
},
{
id: 10,
name: 'Non-fiction',
},
],
},
{
id: 11,
name: 'Toys',
},
];
console.log()
statements will appear here.