From 3ba3024ef7978ca8d07f291bd8a55b55a84775e8 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 14 Feb 2024 17:51:21 -0500 Subject: [PATCH] Handle falsy errors correctly --- packages/react-router/lib/hooks.tsx | 2 +- packages/router/router.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react-router/lib/hooks.tsx b/packages/react-router/lib/hooks.tsx index 0feda4720f..37697ee647 100644 --- a/packages/react-router/lib/hooks.tsx +++ b/packages/react-router/lib/hooks.tsx @@ -697,7 +697,7 @@ export function _renderMatches( let errors = dataRouterState?.errors; if (errors != null) { let errorIndex = renderedMatches.findIndex( - (m) => m.route.id && errors?.[m.route.id] + (m) => m.route.id && errors?.[m.route.id] !== undefined ); invariant( errorIndex >= 0, diff --git a/packages/router/router.ts b/packages/router/router.ts index e949788a06..beb6c485e0 100644 --- a/packages/router/router.ts +++ b/packages/router/router.ts @@ -8,7 +8,6 @@ import { warning, } from "./history"; import type { - ActionFunction, AgnosticDataRouteMatch, AgnosticDataRouteObject, DataStrategyMatch, @@ -25,7 +24,6 @@ import type { HTMLFormMethod, HandlerResult, ImmutableRouteKey, - LoaderFunction, MapRoutePropertiesFunction, MutationFormMethod, RedirectResult, @@ -4214,7 +4212,7 @@ async function callLoaderOrAction( }), loadLazyRouteModule(match.route, mapRouteProperties, manifest), ]); - if (handlerError) { + if (handlerError !== undefined) { throw handlerError; } result = values[0];