Skip to content

Commit 369b100

Browse files
authored
Update Route.MetaArgs to reflect optional data (#13563)
1 parent e4a1789 commit 369b100

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/big-ladybugs-brush.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Update `Route.MetaArgs` to reflect that `data` can be potentially `undefined`
6+
7+
This is primarily for cases where a route `loader` threw an error to it's own `ErrorBoundary`. but it also arises in the case of a 404 which renders the root `ErrorBoundary`/`meta` but the root loader did not run because not routes matched.

packages/react-router/lib/types/route-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type CreateMetaArgs<T extends RouteInfo> = {
6161
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
6262
params: T["params"];
6363
/** The return value for this route's server loader function */
64-
data: T["loaderData"];
64+
data: T["loaderData"] | undefined;
6565
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
6666
error?: unknown;
6767
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */

0 commit comments

Comments
 (0)