Search code examples
javascriptbrowser-history

Same link creates duplicates in location history


In Chrome, If you click the same link many times, all of them will be added to browser location history. Navigating back breaks the navigation logic because it navigates through duplicated locations. if you clicked the same link 3 times then you have to click back button 3 times to navigate the last page

I capture the count of the clicks and I put that count in history.go(-count) but it got failed in some cases

 if(this.page === 'page-link'){
  this.count++;
}

note : iam passing this count value through redux

Another file:

let counts = this.count;
history.go(-(counts));

I am expecting that if I have click same link many times, but when I click on the back button it should navigate to the last page


Solution

  • Keep pointer event non for particular button when that page is opened.so that the page is not count when tap second time on the same button