Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
Display bug on a dropdown list in react js

Hello everyone I hope you are well I am a beginner in react js and I would like to display a dynamic dropdown list in react js for this I use my child component History and I pass him a pros "data" however I have a display bu when I add an element in my table "data"

I would like to know if someone has already had this problem and if he could help me

Component child History

import React, { useEffect, useState } from "react";
import imgFolder from "../assets/tree-viewer-img/folder.svg"

function History({data}) {
  
  useEffect(() => {
    var toggler = document.getElementsByClassName("caret");
    var i;

    for (i = 0; i < toggler.length; i++) {
      toggler[i].addEventListener("click", function(e) {
        console.log("๐Ÿš€ ~ file: History.js ~ line 11 ~ e", e);
        this.parentElement.querySelector(".nested").classList.toggle("active");
        this.classList.toggle("caret-down");
      });
    }
  }, [data]);

  return (
    <div className="container_history">
      <ul id="myUL">
        {data.map((item, index) => {
          return (
            <li key={index}>
              <span className="caret">
                <img src={imgFolder} alt="" />
                {item.name}
              </span>

              <ul className="nested">
                {item.children.map((list, indexOf) => {
                  return <li key={indexOf}>{list.name}</li>;
                })}
              </ul>
            </li>
          );
        })}
      </ul>
    </div>
  );
}
export default History;

in my props "data"

[
    {
      name: "Model 3D",
      children: [
        { name: "Geometry", children: [] },
        { name: "Texture", children: [] },
      ],
    },
  ]

problem view scene

about 4 years ago ยท Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!