Skip to content

Commit e2822b9

Browse files
committed
Remove deprecated detectErrorBoundaries
1 parent 4996fbe commit e2822b9

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
@@ -17,7 +17,6 @@ import type {
1717
DataStrategyFunctionArgs,
1818
DeferredData,
1919
DeferredResult,
20-
DetectErrorBoundaryFunction,
2120
ErrorResult,
2221
FormEncType,
2322
FormMethod,
@@ -375,10 +374,6 @@ export interface RouterInit {
375374
routes: AgnosticRouteObject[];
376375
history: History;
377376
basename?: string;
378-
/**
379-
* @deprecated Use `mapRouteProperties` instead
380-
*/
381-
detectErrorBoundary?: DetectErrorBoundaryFunction;
382377
mapRouteProperties?: MapRoutePropertiesFunction;
383378
future?: Partial<FutureConfig>;
384379
hydrationData?: HydrationState;
@@ -810,18 +805,7 @@ export function createRouter(init: RouterInit): Router {
810805
"You must provide a non-empty routes array to createRouter"
811806
);
812807

813-
let mapRouteProperties: MapRoutePropertiesFunction;
814-
if (init.mapRouteProperties) {
815-
mapRouteProperties = init.mapRouteProperties;
816-
} else if (init.detectErrorBoundary) {
817-
// If they are still using the deprecated version, wrap it with the new API
818-
let detectErrorBoundary = init.detectErrorBoundary;
819-
mapRouteProperties = (route) => ({
820-
hasErrorBoundary: detectErrorBoundary(route),
821-
});
822-
} else {
823-
mapRouteProperties = defaultMapRouteProperties;
824-
}
808+
let mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
825809

826810
// Routes keyed by ID
827811
let manifest: RouteManifest = {};
@@ -3399,10 +3383,6 @@ export const UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
33993383

34003384
export interface CreateStaticHandlerOptions {
34013385
basename?: string;
3402-
/**
3403-
* @deprecated Use `mapRouteProperties` instead
3404-
*/
3405-
detectErrorBoundary?: DetectErrorBoundaryFunction;
34063386
mapRouteProperties?: MapRoutePropertiesFunction;
34073387
future?: {};
34083388
}
@@ -3418,22 +3398,8 @@ export function createStaticHandler(
34183398

34193399
let manifest: RouteManifest = {};
34203400
let basename = (opts ? opts.basename : null) || "/";
3421-
let mapRouteProperties: MapRoutePropertiesFunction;
3422-
if (opts?.mapRouteProperties) {
3423-
mapRouteProperties = opts.mapRouteProperties;
3424-
} else if (opts?.detectErrorBoundary) {
3425-
// If they are still using the deprecated version, wrap it with the new API
3426-
let detectErrorBoundary = opts.detectErrorBoundary;
3427-
mapRouteProperties = (route) => ({
3428-
hasErrorBoundary: detectErrorBoundary(route),
3429-
});
3430-
} else {
3431-
mapRouteProperties = defaultMapRouteProperties;
3432-
}
3433-
// Config driven behavior flags
3434-
let future = {
3435-
...opts?.future,
3436-
};
3401+
let mapRouteProperties =
3402+
opts?.mapRouteProperties || defaultMapRouteProperties;
34373403

34383404
let dataRoutes = convertRoutesToDataRoutes(
34393405
routes,
@@ -4677,10 +4643,9 @@ async function loadLazyRouteModule(
46774643
// updates and remove the `lazy` function so we don't resolve the lazy
46784644
// route again.
46794645
Object.assign(routeToUpdate, {
4680-
// To keep things framework agnostic, we use the provided
4681-
// `mapRouteProperties` (or wrapped `detectErrorBoundary`) function to
4682-
// set the framework-aware properties (`element`/`hasErrorBoundary`) since
4683-
// the logic will differ between frameworks.
4646+
// To keep things framework agnostic, we use the provided `mapRouteProperties`
4647+
// function to set the framework-aware properties (`element`/`hasErrorBoundary`)
4648+
// since the logic will differ between frameworks.
46844649
...mapRouteProperties(routeToUpdate),
46854650
lazy: undefined,
46864651
});

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,6 @@ export interface ShouldRevalidateFunction {
219219
(args: ShouldRevalidateFunctionArgs): boolean;
220220
}
221221

222-
/**
223-
* Function provided by the framework-aware layers to set `hasErrorBoundary`
224-
* from the framework-aware `errorElement` prop
225-
*
226-
* @deprecated Use `mapRouteProperties` instead
227-
*/
228-
export interface DetectErrorBoundaryFunction {
229-
(route: AgnosticRouteObject): boolean;
230-
}
231-
232222
export interface DataStrategyMatch
233223
extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
234224
shouldLoad: boolean;

0 commit comments

Comments
 (0)