daniel-hauser / react-organizational-chart

Simple react hierarchy tree - any React children accepted for nodes
https://daniel-hauser.github.io/react-organizational-chart
MIT License
182 stars 36 forks source link

OnClick functionality does not work for Tree Nodes #39

Closed adheesh24 closed 2 years ago

adheesh24 commented 2 years ago

Is there a way to trigger an event when clicked on a Node? I want to open a pop-up on click of the nodes.

Any help would be appreciated.

avishmonga commented 2 years ago

you can add div in lable and add onclick that only

daniel-hauser commented 2 years ago

The best way to do it is to handle the events in the component you pass as label.

const ExampleTree = () => (
  <Tree label={<div>Root</div>}>
    <TreeNode label={<button onClick={() => console.log('clicked')}>Child 1</button>} />
  </Tree>
);