Skip to content

'useRouteMatch' is not exported from 'react-router-dom' #187

Description

I'm submitting a:

  • Bug report
  • Feature request
  • Other (Describe below)

Current behavior

Getting the next error on npm start

Failed to compile.

./node_modules/@okta/okta-react/bundles/okta-react.esm.js
Attempted import error: 'useRouteMatch' is not exported from 'react-router-dom'.

Following the Okta Sign-In Widget and React guide

Packages I use:

{
    "@okta/okta-auth-js": "^5.1.1",
    "@okta/okta-react": "^6.0.0",
    "@okta/okta-signin-widget": "^5.7.3",
    "react-router-dom": "^6.0.1",
}

The okta-react.esm.js code parts:

import { useRouteMatch, Route } from 'react-router-dom';
...
var match = useRouteMatch(routeProps);

Expected behavior

Compilation without errors

Minimal reproduction of the problem with instructions

Just follow the guide above

Extra information about the use case/user story you are trying to implement

I think the problem is the 6th version of the React Router Dom.

UPD: Found the solution

You should use useMatch in place of useRouteMatch

Environment

  • React version: 17.0.2
  • Node version (node -v): 16.11.1

Configuration

  • Okta application type: Single Page App (SPA)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions