I’m trying to add a button inside the component which is link ()as a whole already. But I want my button to be unlinked but also positioned inside that linked component.
I mean when I click on that button it should do what function I assigned using (onClick)but not redirecting to the component Link.
I’m working with SPA using React.
return(
{name}
{cuisine}
Rating: {rating}
Delivery Time: (deliverytime+”minutes”}
{costfortwo}
Add/button
2
Answers
The
onClick
handler of your Button receives anEvent
object as first parameter, try to call thepreventDefault
method on this object.you can use
stopPropogation
function to achieve that purpose.