Skip to content

Tag: preventdefault

Reactjs prevent form submission not working

I’m following a tutorial and I’m trying to have a form that does not reload when submitted to do this I’m trying to use e.preventDefault(); however this is not working and the page is reloading on submission anyway here is my code: the only major thing different that I’m doing from the tutorial is using a bootstrap 5 modal, but

Prevent navigation on anchor that has routerLink

In my markup, there is [routerLink]=”(onLink | async).linkURL” And when its there, I’m unable to stop the navigation from happening when user clicks it. If I remove [routerLink]=”(onLink | async).linkURL”, the navigation is stopped as expected. Is there a way I can stop the navigation here? I’m unable to remove [routerLink]=”(onLink | async).linkURL” from the markup. My js below is