I have a <Link> element from React Router that I don't want to open in a new tab or existing tab, but e.preventDefault() isn't working:
constructor(props) {
super(props);
this.loadLink = this.loadLink.bind(this);
}
loadLink(e) {
e.preventDefault();
const id = null || e.target.id;
this.props.onLink(id);
}
render() {
return (
<Link id="my-id" ref="my-id" onClick={this.loadLink} to="/some-url">Some link</Link>
);
}
I've tried e.stopPropagation() and e.nativeEvent.stopImmediatePropagation(), tried converting it from <Link> to a regular <a> tag, but no matter what clicking the link always opens in a new tab.
I've checked via dev tools and it's the only custom event handler attached to that link.
Any ideas what this could be or how to trace?