Skip to content

Commit 64f0d0a

Browse files
authored
Remove deprecated detectErrorBoundaries (#11751)
1 parent 0457dbe commit 64f0d0a

File tree

4 files changed

+12
-52
lines changed

4 files changed

+12
-52
lines changed

.changeset/two-countries-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": major
3+
---
4+
5+
Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties`

packages/react-router/lib/dom/server.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function getStatelessNavigator() {
248248

249249
type CreateStaticHandlerOptions = Omit<
250250
RouterCreateStaticHandlerOptions,
251-
"detectErrorBoundary" | "mapRouteProperties"
251+
"mapRouteProperties"
252252
>;
253253

254254
/**

packages/react-router/lib/router/router.ts

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
DataResult,
1616
DataStrategyFunction,
1717
DataStrategyFunctionArgs,
18-
DetectErrorBoundaryFunction,
1918
ErrorResult,
2019
FormEncType,
2120
FormMethod,
@@ -365,10 +364,6 @@ export interface RouterInit {
365364
routes: AgnosticRouteObject[];
366365
history: History;
367366
basename?: string;
368-
/**
369-
* @deprecated Use `mapRouteProperties` instead
370-
*/
371-
detectErrorBoundary?: DetectErrorBoundaryFunction;
372367
mapRouteProperties?: MapRoutePropertiesFunction;
373368
future?: Partial<FutureConfig>;
374369
hydrationData?: HydrationState;
@@ -799,18 +794,7 @@ export function createRouter(init: RouterInit): Router {
799794
"You must provide a non-empty routes array to createRouter"
800795
);
801796

802-
let mapRouteProperties: MapRoutePropertiesFunction;
803-
if (init.mapRouteProperties) {
804-
mapRouteProperties = init.mapRouteProperties;
805-
} else if (init.detectErrorBoundary) {
806-
// If they are still using the deprecated version, wrap it with the new API
807-
let detectErrorBoundary = init.detectErrorBoundary;
808-
mapRouteProperties = (route) => ({
809-
hasErrorBoundary: detectErrorBoundary(route),
810-
});
811-
} else {
812-
mapRouteProperties = defaultMapRouteProperties;
813-
}
797+
let mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
814798

815799
// Routes keyed by ID
816800
let manifest: RouteManifest = {};
@@ -3287,10 +3271,6 @@ export function createRouter(init: RouterInit): Router {
32873271

32883272
export interface CreateStaticHandlerOptions {
32893273
basename?: string;
3290-
/**
3291-
* @deprecated Use `mapRouteProperties` instead
3292-
*/
3293-
detectErrorBoundary?: DetectErrorBoundaryFunction;
32943274
mapRouteProperties?: MapRoutePropertiesFunction;
32953275
future?: {};
32963276
}
@@ -3306,22 +3286,8 @@ export function createStaticHandler(
33063286

33073287
let manifest: RouteManifest = {};
33083288
let basename = (opts ? opts.basename : null) || "/";
3309-
let mapRouteProperties: MapRoutePropertiesFunction;
3310-
if (opts?.mapRouteProperties) {
3311-
mapRouteProperties = opts.mapRouteProperties;
3312-
} else if (opts?.detectErrorBoundary) {
3313-
// If they are still using the deprecated version, wrap it with the new API
3314-
let detectErrorBoundary = opts.detectErrorBoundary;
3315-
mapRouteProperties = (route) => ({
3316-
hasErrorBoundary: detectErrorBoundary(route),
3317-
});
3318-
} else {
3319-
mapRouteProperties = defaultMapRouteProperties;
3320-
}
3321-
// Config driven behavior flags
3322-
let future = {
3323-
...opts?.future,
3324-
};
3289+
let mapRouteProperties =
3290+
opts?.mapRouteProperties || defaultMapRouteProperties;
33253291

33263292
let dataRoutes = convertRoutesToDataRoutes(
33273293
routes,
@@ -4536,10 +4502,9 @@ async function loadLazyRouteModule(
45364502
// updates and remove the `lazy` function so we don't resolve the lazy
45374503
// route again.
45384504
Object.assign(routeToUpdate, {
4539-
// To keep things framework agnostic, we use the provided
4540-
// `mapRouteProperties` (or wrapped `detectErrorBoundary`) function to
4541-
// set the framework-aware properties (`element`/`hasErrorBoundary`) since
4542-
// the logic will differ between frameworks.
4505+
// To keep things framework agnostic, we use the provided `mapRouteProperties`
4506+
// function to set the framework-aware properties (`element`/`hasErrorBoundary`)
4507+
// since the logic will differ between frameworks.
45434508
...mapRouteProperties(routeToUpdate),
45444509
lazy: undefined,
45454510
});

packages/react-router/lib/router/utils.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,6 @@ export interface ShouldRevalidateFunction {
204204
(args: ShouldRevalidateFunctionArgs): boolean;
205205
}
206206

207-
/**
208-
* Function provided by the framework-aware layers to set `hasErrorBoundary`
209-
* from the framework-aware `errorElement` prop
210-
*
211-
* @deprecated Use `mapRouteProperties` instead
212-
*/
213-
export interface DetectErrorBoundaryFunction {
214-
(route: AgnosticRouteObject): boolean;
215-
}
216-
217207
export interface DataStrategyMatch
218208
extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
219209
shouldLoad: boolean;

0 commit comments

Comments
 (0)