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

148
Visualizações
PrimeReact Tree onNodeClick function is not being called

I'm using PrimeReact's Tree component with a drag and drop, single selection, and an onNodeClick event for the node. The drag and drop and selection is working fine but the onNodeClick event is just not firing.


         <Tree
          value={nodes}
          expandedKeys={expandedKeys}
          onToggle={(e) => setExpandedKeys(e.value)}
          dragdropScope="demo"
          onDragDrop={(event) => setNodes(event.value)}
          onContextMenu={(event) => cm.current.show(event.originalEvent)}
          selectionMode="single"
          selectionKeys={selectedKey}
          onSelectionChange={(e) => setSelectedKey(e.value)}
          onNodeClick={(event) => openFile(event)}
        />

However, the event fires when the function is called directly:


         <Tree
          value={nodes}
          expandedKeys={expandedKeys}
          onToggle={(e) => setExpandedKeys(e.value)}
          dragdropScope="demo"
          onDragDrop={(event) => setNodes(event.value)}
          onContextMenu={(event) => cm.current.show(event.originalEvent)}
          selectionMode="single"
          selectionKeys={selectedKey}
          onSelectionChange={(e) => setSelectedKey(e.value)}
          onNodeClick={openFile()}
        />

The problem with the second piece of code is that the event is fired on page load and just keeps firing away.

The first one is probably the correct way to do it as the event contains the node parameters according to documentation but I just can't seem to fire it. What am I doing wrong here?

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