I have these tiles that are clickable which while send the user to some external page plus a button inside of the tile that should route the user to some page inside of the site. The problem with this is that when clicking on the button, both events are fired so it sends the user to the external page + navigates to the internal page.
<div
tabIndex={0}
role="button"
onClick={onClick}
>
<div>
// some markup
<Link href={url} passHref>
<a
role="button"
onClick={(e) => sendUserToInternalPageEvent(e)}
>
// some text
</a>
</Link>
</div>
</div>
The event for sendUserToInternalPageEvent
is using the nextjs event object for the Link component. I'm trying to stop propagation for sendUserToInternalPageEvent
but event.stopPropagation()
is undefined. The goal is for sendUserToInternalPageEvent
to send the user to an internal page while using the nextjs Link element and have onClick
send the user to the external page.
stopPropagation
on anchor using Link, you could try to wrap it, e.g.<div><a ...>...</a></div>
– Intubate