-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: update error handling in MatchInner to access error data directly #4746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f907711
a3bdffd
35ec117
0b6cccb
2e28b59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ export function renderRouteNotFound( | |
) { | ||
if (!route.options.notFoundComponent) { | ||
if (router.options.defaultNotFoundComponent) { | ||
return <router.options.defaultNotFoundComponent data={data} /> | ||
return <router.options.defaultNotFoundComponent {...data} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part causes the structure to become nested like |
||
} | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
|
@@ -23,5 +23,5 @@ export function renderRouteNotFound( | |
return <DefaultGlobalNotFound /> | ||
} | ||
|
||
return <route.options.notFoundComponent data={data} /> | ||
return <route.options.notFoundComponent {...data} /> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import type { | |
RouteMatch, | ||
} from './Matches' | ||
import type { RootRouteId } from './root' | ||
import type { ParseRoute, RouteById, RoutePaths } from './routeInfo' | ||
import type { ParseRoute, RouteById, RouteIds, RoutePaths } from './routeInfo' | ||
import type { AnyRouter, RegisteredRouter } from './router' | ||
import type { BuildLocationFn, NavigateFn } from './RouterProvider' | ||
import type { | ||
|
@@ -1322,9 +1322,11 @@ export type ErrorComponentProps<TError = Error> = { | |
info?: { componentStack: string } | ||
reset: () => void | ||
} | ||
export type NotFoundRouteProps = { | ||
// TODO: Make sure this is `| null | undefined` (this is for global not-founds) | ||
data: unknown | ||
|
||
export type NotFoundRouteProps<TData = unknown> = { | ||
data?: TData | ||
isNotFound: boolean | ||
routeId: RouteIds<RegisteredRouter['routeTree']> | ||
Comment on lines
+1326
to
+1329
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated this type. This enforces stricter type checking on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, the can you please check this change? |
||
} | ||
|
||
export class BaseRoute< | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this
any
instead ofunknown
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because the type of
notFoundRouteProps
was changed fromunknown
toPartial<NotFoundError>
,and the
data
inNotFoundError
is currently typed asany
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change it there to unknown? to force people to add some runtime type checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean it should be reverted the change?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I menthioned here,
notFoundRouteProps
can contain not onlydata
but also any value of typeNotFoundError
likerouteId
.or is it appropriate to convert the
data
type ofNotFoundError
tounknown
?