Skip to content

After v8 update I receive "_matchRoutes is not a function" when using wrapCreateBrowserRouter #12018

Closed
@Slessi

Description

@Slessi

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

8.0.0

Framework Version

18.3.1

Link to Sentry event

No response

SDK Setup

Sentry.init({
  dsn: '***',
  integrations: [
    Sentry.reactRouterV6BrowserTracingIntegration({
      useEffect,
      useLocation,
      useNavigationType,
      createRoutesFromChildren,
      matchRoutes,
    }),
    Sentry.replayIntegration(),
  ],
  tracesSampleRate: 0.1,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

Steps to Reproduce

I setup my react-router v6 as follows.

export function App() {
  return (
    <RouterProvider
      router={Sentry.wrapCreateBrowserRouter(createBrowserRouter)([
        {
          path: '*',
          element: <RouterEntry />,
          children: [
            /* my routes */
          ],
        },
      ])}
    />
  );
}

Expected Result

Should load my routes 🎉

Actual Result

No routes load, and I see the following console error. I cannot find in the migration guide any changes about this so I assume it is a bug as on v7 this code works. Removing Sentry.wrapCreateBrowserRouter allows the routes to load again.

Uncaught (in promise) TypeError: _matchRoutes is not a function
    at handleNavigation (@sentry_react.js?v=aff74ec4:29421:55)
    at @sentry_react.js?v=aff74ec4:29508:9
    at react-router-dom.js?v=aff74ec4:1257:46
    at Array.forEach (<anonymous>)
    at updateState (react-router-dom.js?v=aff74ec4:1257:22)
    at completeNavigation (react-router-dom.js?v=aff74ec4:1332:5)
    at startNavigation (react-router-dom.js?v=aff74ec4:1507:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: reactIssues related to the Sentry React SDK

    Type

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions