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

149
Views
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
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!