Skip to content

Instantly share code, notes, and snippets.

package march06;
public class Employee {
public int id;
public String name;
public String positon;
public Employee(int id, String name, String positon) {
this.id = id;
this.name = name;
//Styles import here
import "../Styles/Pages/Home.css";
//Styles import here
//Components import here
// import Navbar from '../Components/Navbar';
import CatalogAccordion from "../Components/Sidebar.jsx";
//Components import here
import { useState } from 'react';
// Recursive component to render tree nodes
const RenderTree = ({ node }) => {
const [isOpen, setIsOpen] = useState(true);
const toggle = () => setIsOpen(!isOpen);
return (
<div style={{ marginLeft: '20px' }}>
import { useState, useEffect } from "react";
// Recursive Component to render the tree structure with collapsible and auto-expand functionality on search
const TreeNode = ({ node, isExpandedInitially, onItemClick }) => {
const [isExpanded, setIsExpanded] = useState(isExpandedInitially);
// Update the expand state when the initial expand prop changes (e.g., during search)
useEffect(() => {
setIsExpanded(isExpandedInitially);
}, [isExpandedInitially]);