警告:哈希历史不能 PUSH 相同的路径;新条目不会添加到历史堆栈
Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
我正在使用 react-router-dom 并且在控制台中出现了这个错误。
Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
基本上,问题是如果您在页面 /here
上单击 link 到 /here
,您最终会得到基本上重复的(只是不同的键)位置对象。请确认您在 <Link to='/diff'/>
中推送了不同的路径
查看此 link 以获得更多参考:https://github.com/ReactTraining/react-router/issues/5996
我收到了这条消息。我将路由变量更改为 function
留言前:
const routing = (
<Switch>
...
</Switch>
);
固定为:
const routing = () => (
<Switch>
...
</Switch>
);
使用替换
添加'替换'到导航Link或Link
<NavLink exact to="/myProfile" replace >My Propile</NavLink>
或
<Link to="/myProfile" replace />
我正在使用 react-router-dom 并且在控制台中出现了这个错误。
Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
基本上,问题是如果您在页面 /here
上单击 link 到 /here
,您最终会得到基本上重复的(只是不同的键)位置对象。请确认您在 <Link to='/diff'/>
查看此 link 以获得更多参考:https://github.com/ReactTraining/react-router/issues/5996
我收到了这条消息。我将路由变量更改为 function
留言前:
const routing = (
<Switch>
...
</Switch>
);
固定为:
const routing = () => (
<Switch>
...
</Switch>
);
使用替换
添加'替换'到导航Link或Link
<NavLink exact to="/myProfile" replace >My Propile</NavLink>
或
<Link to="/myProfile" replace />