reactjs 尝试导入错误:未从"react-router-dom"中导出"useLocation"

siv3szwd  于 2023-01-02  发布在  React
关注(0)|答案(2)|浏览(161)
React version:
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-router-dom": "5.0.1",
"react-scripts": "3.4.0",

js代码为

import {useLocation} from "react-router-dom";
const location = useLocation();

......问题出在哪里?

rhfm7lfc

rhfm7lfc2#

尝试卸载并重新安装“react-router-dom”然后,为了安全起见,运行npm inpm start。此外,如果您使用TS,则还必须安装“@types/react-router-dom”作为开发依赖项

相关问题