Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm working on react-router-dom and in console this error is appearing.

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

like image 791
Majid NWL Avatar asked Mar 07 '18 16:03

Majid NWL


2 Answers

Use Replace

add 'replace' to the NavLink or Link

<NavLink exact to="/myProfile" replace >My Propile</NavLink>

or

<Link to="/myProfile" replace />
like image 84
Omer Avatar answered Oct 31 '22 19:10

Omer


Basically, the problem is that if you are on page /here and click a link to /here, you end up with essentially duplicate (just different keys) location objects. Please confirm that your pushing the different paths in <Link to='/diff'/>

checkout this link for more reference: https://github.com/ReactTraining/react-router/issues/5996

like image 21
Sagar Avatar answered Oct 31 '22 19:10

Sagar