Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

63
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda