React Router Warning: Hash history cannot PUSH the same path

Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack

Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack

This warning is really annoying when you using hash router. Moreover it is logged to the console as error, instead of warning. So you see this error every time you click link with current path. And solution? Pretty easy and straight forward:

All we have to do is create higher order function and wrap our Link in it. So let’s create NavLink. And use replace prop. When replace prop is true, clicking the link will replace the current entry in the history stack instead of adding a new one. To get current pathname we use props.location object.

Related Post

PPTP VPN on MAC OS X Sierra, High Sierra and Mojav... PPTP VPN for Mac OS X Introduction PPTP VPN is no longer supported on macOS Sierra and High Sierra and that is just fine, because there are some se...
Translate Selected Text to English on Right Click ... TL;DR; Need instant translation right in context menu? You can accomplish it for free with one line of code in Automator, or you can proc...
Right Click to Create New File on Mac OS X TL;DR; Windows has a lot of cons but it has also some pros. One of them is a smooth way to create empty file on right-click. Mac OS doesn't come with...
Convert HEIC to JPG on Right Click for Free Convert HEIC to JPG on Right-Click In iOS 11 Apple is replacing the JPEG image format with the new HEIC alternative. But what to do when device or p...
Right-Click to Translate (Look Up) with Google Tra... If you are not native english speaker, you may be frustrated with default "look up" options you get after selecting a text and right clicking. There a...
MacBook wifi issue – OS X keeps reconnecting Last few weeks I was facing annoying wifi problems. My mac was reconnecting every 5 minutes. On top of that BSSID was reseting so I saw BSSID changing...
Buy me a coffeeOut of coffee 😱, please help!