diff --git a/.changeset/two-countries-yell.md b/.changeset/two-countries-yell.md new file mode 100644 index 0000000000..de7d6d5098 --- /dev/null +++ b/.changeset/two-countries-yell.md @@ -0,0 +1,5 @@ +--- +"react-router": major +--- + +Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` diff --git a/packages/react-router/lib/dom/server.tsx b/packages/react-router/lib/dom/server.tsx index b4f85bc004..0b9b1e16a8 100644 --- a/packages/react-router/lib/dom/server.tsx +++ b/packages/react-router/lib/dom/server.tsx @@ -248,7 +248,7 @@ function getStatelessNavigator() { type CreateStaticHandlerOptions = Omit< RouterCreateStaticHandlerOptions, - "detectErrorBoundary" | "mapRouteProperties" + "mapRouteProperties" >; /** diff --git a/packages/react-router/lib/router/router.ts b/packages/react-router/lib/router/router.ts index 0e7af99ff3..d43c8b395c 100644 --- a/packages/react-router/lib/router/router.ts +++ b/packages/react-router/lib/router/router.ts @@ -15,7 +15,6 @@ import type { DataResult, DataStrategyFunction, DataStrategyFunctionArgs, - DetectErrorBoundaryFunction, ErrorResult, FormEncType, FormMethod, @@ -365,10 +364,6 @@ export interface RouterInit { routes: AgnosticRouteObject[]; history: History; basename?: string; - /** - * @deprecated Use `mapRouteProperties` instead - */ - detectErrorBoundary?: DetectErrorBoundaryFunction; mapRouteProperties?: MapRoutePropertiesFunction; future?: Partial; hydrationData?: HydrationState; @@ -799,18 +794,7 @@ export function createRouter(init: RouterInit): Router { "You must provide a non-empty routes array to createRouter" ); - let mapRouteProperties: MapRoutePropertiesFunction; - if (init.mapRouteProperties) { - mapRouteProperties = init.mapRouteProperties; - } else if (init.detectErrorBoundary) { - // If they are still using the deprecated version, wrap it with the new API - let detectErrorBoundary = init.detectErrorBoundary; - mapRouteProperties = (route) => ({ - hasErrorBoundary: detectErrorBoundary(route), - }); - } else { - mapRouteProperties = defaultMapRouteProperties; - } + let mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties; // Routes keyed by ID let manifest: RouteManifest = {}; @@ -3287,10 +3271,6 @@ export function createRouter(init: RouterInit): Router { export interface CreateStaticHandlerOptions { basename?: string; - /** - * @deprecated Use `mapRouteProperties` instead - */ - detectErrorBoundary?: DetectErrorBoundaryFunction; mapRouteProperties?: MapRoutePropertiesFunction; future?: {}; } @@ -3306,22 +3286,8 @@ export function createStaticHandler( let manifest: RouteManifest = {}; let basename = (opts ? opts.basename : null) || "/"; - let mapRouteProperties: MapRoutePropertiesFunction; - if (opts?.mapRouteProperties) { - mapRouteProperties = opts.mapRouteProperties; - } else if (opts?.detectErrorBoundary) { - // If they are still using the deprecated version, wrap it with the new API - let detectErrorBoundary = opts.detectErrorBoundary; - mapRouteProperties = (route) => ({ - hasErrorBoundary: detectErrorBoundary(route), - }); - } else { - mapRouteProperties = defaultMapRouteProperties; - } - // Config driven behavior flags - let future = { - ...opts?.future, - }; + let mapRouteProperties = + opts?.mapRouteProperties || defaultMapRouteProperties; let dataRoutes = convertRoutesToDataRoutes( routes, @@ -4536,10 +4502,9 @@ async function loadLazyRouteModule( // updates and remove the `lazy` function so we don't resolve the lazy // route again. Object.assign(routeToUpdate, { - // To keep things framework agnostic, we use the provided - // `mapRouteProperties` (or wrapped `detectErrorBoundary`) function to - // set the framework-aware properties (`element`/`hasErrorBoundary`) since - // the logic will differ between frameworks. + // To keep things framework agnostic, we use the provided `mapRouteProperties` + // function to set the framework-aware properties (`element`/`hasErrorBoundary`) + // since the logic will differ between frameworks. ...mapRouteProperties(routeToUpdate), lazy: undefined, }); diff --git a/packages/react-router/lib/router/utils.ts b/packages/react-router/lib/router/utils.ts index 1523965efb..67fc67bf5b 100644 --- a/packages/react-router/lib/router/utils.ts +++ b/packages/react-router/lib/router/utils.ts @@ -204,16 +204,6 @@ export interface ShouldRevalidateFunction { (args: ShouldRevalidateFunctionArgs): boolean; } -/** - * Function provided by the framework-aware layers to set `hasErrorBoundary` - * from the framework-aware `errorElement` prop - * - * @deprecated Use `mapRouteProperties` instead - */ -export interface DetectErrorBoundaryFunction { - (route: AgnosticRouteObject): boolean; -} - export interface DataStrategyMatch extends AgnosticRouteMatch { shouldLoad: boolean;