Okta Auth <Security/> 组件似乎与 reach-router 有问题

Okta Auth <Security/> Component seems to have a problem with reach-router

这是我在 运行 应用程序后遇到的错误。

错误./node_modules/@okta/okta-react/bundles/okta-react.esm.js 284:14-27

在“react-router-dom”中找不到导出“useRouteMatch”(导入为“useRouteMatch”)(可能导出:BrowserRouter、HashRouter、Link、MemoryRouter、NavLink, 导航, 出口, 路线, 路由器, 路线, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createRoutesFromChildren, createSearchParams, generatePath, matchPath, matchRoutes, renderMatches, resolvePath, unstable_HistoryRouter, useHref, useInRouterContext, useLinkClickHandler, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams)

这是我的 Index.tsx 文件中的代码。

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import "mdb-react-ui-kit/dist/css/mdb.min.css";

import { Security } from "@okta/okta-react";
import { OktaAuth } from "@okta/okta-auth-js";

const config = {
  clientId: "*********************",
  issuer: "https://****************/oauth2/default",
  redirectUri: "http://localhost:3000/login/callback",
  scopes: ["openid", "profile", "email"],
  pkce: true,
};

const oktaAuth = new OktaAuth(config);

const restoreOriginalUri = () => {
  // Callback function to restore URI during login
};

ReactDOM.render(
  <React.StrictMode>
    <Security oktaAuth={oktaAuth} restoreOriginalUri={restoreOriginalUri}>
      <App />
    </Security>
  </React.StrictMode>,
  document.getElementById("root")
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: 
reportWebVitals();

我会继续预感并假设您使用比 v5 更新的 react-router 版本。

根据https://github.com/okta/okta-react/issues/187

@okta/okta-react currently only supports react-router v5. We are currently investigating v6 support