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.

Buy me a coffeeOut of coffee 😱, please help!