为什么 React Router 历史长度在刷新时会增加? [英] Why does the React Router history length increase on refresh?

查看:44
本文介绍了为什么 React Router 历史长度在刷新时会增加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次打开app,history对象的长度(由useHistory Hook返回) 是 3.

The first time I open the app, the length of the history object (returned by the useHistory Hook) is 3.

每次进一步刷新时,长度都会增加.这是为什么?生产中也会出现这种情况吗?

On every further refresh, the length gets incremented. Why is that? Does this happen in production too?

环境:

  • create-react-app@3.2.0
  • react-router@5.1.2
  • react-router-dom@5.1.2

推荐答案

  • 反应路由器@5.1.2
  • react-router-dom@5.1.2

我认为你不需要同时使用 react-router-domreact-router.

I think you don't need to use react-router-dom and react-router together.

仅使用 react-router-dom,如 react-router-dom &react-router-native 在核心使用 react-router

Use only react-router-dom, as react-router-dom & react-router-native uses react-router at core

这篇关于为什么 React Router 历史长度在刷新时会增加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆