gpt4 book ai didi

reactjs - 尝试导入错误: 'useRouteMatch' is not exported from 'react-router-dom'

转载 作者:行者123 更新时间:2023-12-03 13:34:01 25 4
gpt4 key购买 nike

当我尝试从react-router-dom模块导入useRouteMatch时出现此错误,出现此错误:

Attempted import error: 'useRouteMatch' is not exported from 'react-router-dom'.

我的react-router-dom模块版本是否错误?

import {
BrowserRouter as Router,
Switch,
Route,
Link,
useRouteMatch,
useParams
} from "react-router-dom";

我查看了模块的导出,事实上,它没有导出。我的版本有误吗?

import _BrowserRouter from "./BrowserRouter";
export { _BrowserRouter as BrowserRouter };
import _HashRouter from "./HashRouter";
export { _HashRouter as HashRouter };
import _Link from "./Link";
export { _Link as Link };
import _MemoryRouter from "./MemoryRouter";
export { _MemoryRouter as MemoryRouter };
import _NavLink from "./NavLink";
export { _NavLink as NavLink };
import _Prompt from "./Prompt";
export { _Prompt as Prompt };
import _Redirect from "./Redirect";
export { _Redirect as Redirect };
import _Route from "./Route";
export { _Route as Route };
import _Router from "./Router";
export { _Router as Router };
import _StaticRouter from "./StaticRouter";
export { _StaticRouter as StaticRouter };
import _Switch from "./Switch";
export { _Switch as Switch };
import _generatePath from "./generatePath";
export { _generatePath as generatePath };
import _matchPath from "./matchPath";
export { _matchPath as matchPath };
import _withRouter from "./withRouter";
export { _withRouter as withRouter };

请帮忙,我需要你的大脑:)

最佳答案

如果从 v5 升级到 v6,请根据升级指南将 useRouteMatch 替换为 useMatch...

React Router Upgrading from v5

关于reactjs - 尝试导入错误: 'useRouteMatch' is not exported from 'react-router-dom' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58399859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com