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?