Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

64
Vistas
How can I push children in object state? I want to add children in any place off tree where parent key is match
const [treeData, setTreeData] = useState([
      {
        title: 'parent 1',
        key: '0-0',
        icon: <UserAddOutlined />,
        children: [
          {
            title: 'parent 1-0',
            key: '0-0-0',
            icon: <UserAddOutlined />,
            children: [
              {
                title: 'leaf',
                key: '0-0-0-0',
                icon: <UserAddOutlined />,
              },
              {
                title: 'leaf',
                key: '0-0-0-1',
                icon: <UserAddOutlined />,
              },
            ],
          },
          {
            title: 'parent 1-1',
            key: '0-0-1',
            icon: <UserAddOutlined />,
            children: [
              {
                title: 'sss',
                key: '0-0-1-0',
                icon: <UserAddOutlined />,
              },
            ],
          },
        ],
      },
    ]);


const insertDataHandler = (formData) =>{

  // i need to add this element on specific parent's children list
  const parentId = formData.pId;
  let element = {
    title: formData.nNode,
    key: formData.Id,
    icon: <UserAddOutlined />,
  }
}

in insertDataHandler the element was created, and also I have a parent id so what I need to do is the parent id will check all the keys of treeData and add to this specific parent's children's array where key is match, if the children are not exist then create the array then insert into that array

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda