Skip to content

version 7.21.0 CreateRouterFunction's RouteObject doesn't support errorElement type .  #6264

@dante01yoon

Description

@dante01yoon

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which package are you using?

@sentry/react

SDK Version

7.21.0

Framework Version

React18, react-router-dom v6.4.1

Link to Sentry event

No response

Steps to Reproduce

Greetings.
Seems 7.21.0's wrapCreateBrowserRouter doesn't support errorElement types?

const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter);

const router = sentryCreateBrowserRouter([
  {
    element: <Wrapper />,
    errorElement: <ErrorPage />,
    children: [
      {
        ... 

your createRouterFunction types looks like below.

export declare function wrapCreateBrowserRouter(createRouterFunction: CreateRouterFunction): CreateRouterFunction;

export declare type CreateRouterFunction = (routes: RouteObject[], opts?: any) => Router;

export declare type RouteObject = IndexRouteObject | NonIndexRouteObject;


export interface NonIndexRouteObject {
    caseSensitive?: boolean;
    children?: RouteObject[];
    element?: React.ReactNode | null;
    index?: any;
    path?: string;
}
export interface IndexRouteObject {
    caseSensitive?: boolean;
    children?: undefined;
    element?: React.ReactNode | null;
    index: any;
    path?: string;
}

the actual RouteObject types of react-router-dom below.

export interface RouteObject extends AgnosticRouteObject {
    children?: RouteObject[];
    element?: React.ReactNode | null;
    errorElement?: React.ReactNode | null;
}

Expected Result

Seems errorElement shouldn't emit type error ?

Actual Result

스크린샷 2022-11-23 오전 9 00 08

Metadata

Metadata

Assignees

Labels

Package: reactIssues related to the Sentry React SDK

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions