I have this component code:
const myCardItem = ({ item }) => {
function clickItem(){
alert('Item clicked');
}
function clickMe(){
alert('Button clicked');
}
return (
<div className="myCardItem" onClick={clickItem}>
<i className="fa fa-clock-o"/> {item.planDate}
<br />
<i className="fa fa-location-arrow"/> {item.destination}
<br />
<Button bsStyle="primary" onClick={clickMe}>Click Me</Button>
</div>
);
}
If I click the button I get first:
Followed by:
Which makes sense, because the button is a child under the myCardItem. But that's not what I want. Clicking the myCardItem
will load a new view, while clicking the button would open a modal dialog. Having both go off would break the page.
How can I prevent the parent click being called?
It's not as easy as doing a return false in clickMe()
...