I need help with my JSX code:
<div id="parent" onClick={clickOnParent} style={{ width: 100, height: 100 }}>
<div id="child" onClick={clickOnChild} style={{ width: 20, height: 20 }} />
</div>
When I click on the parent
element (outside of the child
), it triggers clickOnParent
. But when I click on the child
element, both clickOnParent
and clickOnChild
are triggered. I want to only trigger clickOnChild
when clicking directly on the child
, ignoring clickOnParent
. How can I achieve this?