javascript - react-router-bootstrap LinkContainer 组件失败并出现 TypeError (0 , _reactRouterDom.withRouter) is not a function
问题描述
我一直在使用 react-router-bootstrap 反应库中的 LinkContainer 一段时间,但目前在我导入它时它会抛出此错误:
TypeError (0 , _reactRouterDom.withRouter) 不是函数
请帮我调试一下。
解决方案
你必须选择,要么降级你的 react-router-dom 版本(到 v5.3.0),所以方法 withRouter 将再次可用(由 react-router-bootstrap 使用)或者你关闭 react-router-bootstrap 并使用 useNavigate钩:
const navigate = useNavigate();
...
<Nav.Link onClick={() => navigate('configuration')}>
推荐阅读
- python - python中从零开始的朴素贝叶斯分类器?
- java - 如何在 Eclipse 中为我的 java 应用程序创建 .keystore 文件
- reactjs - 如何在功能组件内成功调度 redux 后检索数据
- kubernetes - 检测 pod 是否使用任何类型的本地存储
- c++ - C++中可重用的成员函数
- azure-devops - 为什么我们在 Azure Devops 中使用管道下的环境?并且在创建构建/发布方面是否有任何每月/每年的限制?
- python - 使用 Rich 设置不同的背景颜色
- python - 集群数据的可视化
- r - 在 echarts4r 中删除千位逗号
- anylogic - 限制由 if else 函数选择的托盘架的空间