File tree Expand file tree Collapse file tree 3 files changed +12
-16
lines changed Expand file tree Collapse file tree 3 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,11 @@ export {
209
209
} ;
210
210
211
211
function enhanceAgnosticRoute ( route : RouteObject ) {
212
- let updates : Partial < RouteObject > = { } ;
212
+ let updates : Partial < RouteObject > & { hasErrorBoundary : boolean } = {
213
+ // Note: this check also occurs in createRoutesFromChildren so update
214
+ // there if you change this -- please and thank you!
215
+ hasErrorBoundary : route . ErrorBoundary != null || route . errorElement != null ,
216
+ } ;
213
217
214
218
if ( route . Component ) {
215
219
if ( __DEV__ ) {
@@ -243,12 +247,6 @@ function enhanceAgnosticRoute(route: RouteObject) {
243
247
} ) ;
244
248
}
245
249
246
- // Note: this check also occurs in createRoutesFromChildren so update
247
- // there if you change this -- please and thank you!
248
- if ( route . ErrorBoundary || route . errorElement ) {
249
- updates . hasErrorBoundary = true ;
250
- }
251
-
252
250
return updates ;
253
251
}
254
252
Original file line number Diff line number Diff line change @@ -637,21 +637,17 @@ export function _renderMatches(
637
637
// Only data routers handle errors
638
638
let errorElement : React . ReactNode | null = null ;
639
639
if ( dataRouterState ) {
640
- if ( match . route . ErrorBoundary ) {
641
- errorElement = < match . route . ErrorBoundary /> ;
642
- } else {
643
- errorElement = match . route . errorElement || defaultErrorElement ;
644
- }
640
+ errorElement = match . route . errorElement || defaultErrorElement ;
645
641
}
646
642
let matches = parentMatches . concat ( renderedMatches . slice ( 0 , index + 1 ) ) ;
647
643
let getChildren = ( ) => {
648
- let children : React . ReactNode = outlet ;
644
+ let children : React . ReactNode ;
649
645
if ( error ) {
650
646
children = errorElement ;
651
- } else if ( match . route . Component ) {
652
- children = < match . route . Component /> ;
653
647
} else if ( match . route . element ) {
654
648
children = match . route . element ;
649
+ } else {
650
+ children = outlet ;
655
651
}
656
652
return (
657
653
< RenderedRoute
Original file line number Diff line number Diff line change @@ -181,7 +181,9 @@ export interface DetectErrorBoundaryFunction {
181
181
* properties from framework-agnostic properties
182
182
*/
183
183
export interface EnhanceAgnosticRouteFunction {
184
- ( route : AgnosticRouteObject ) : Record < string , any > ;
184
+ ( route : AgnosticRouteObject ) : {
185
+ hasErrorBoundary : boolean ;
186
+ } & Record < string , any > ;
185
187
}
186
188
187
189
/**
You can’t perform that action at this time.
0 commit comments