JSFiddle - React, Tailwind, and code Playground

HTML

<a href="">Foo</a>

JavaScript

var a = document.getElementsByTagName('a');
for(i=0 ; i<a.length ; i++){
  a[i].addEventListener('click', function(e) {
    if (this.href === window.location.href) {
        e.preventDefault();
    }
});
}