@@ -428,15 +428,18 @@ function DefaultErrorElement() {
428
428
let error = useRouteError ( ) ;
429
429
let message = isRouteErrorResponse ( error )
430
430
? `${ error . status } ${ error . statusText } `
431
- : error ?. message || JSON . stringify ( error ) ;
431
+ : error instanceof Error
432
+ ? error . message
433
+ : JSON . stringify ( error ) ;
434
+ let stack = error instanceof Error ? error . stack : null ;
432
435
let lightgrey = "rgba(200,200,200, 0.5)" ;
433
436
let preStyles = { padding : "0.5rem" , backgroundColor : lightgrey } ;
434
437
let codeStyles = { padding : "2px 4px" , backgroundColor : lightgrey } ;
435
438
return (
436
439
< >
437
440
< h2 > Unhandled Thrown Error!</ h2 >
438
441
< h3 style = { { fontStyle : "italic" } } > { message } </ h3 >
439
- { error ?. stack ? < pre style = { preStyles } > { error ?. stack } </ pre > : null }
442
+ { stack ? < pre style = { preStyles } > { stack } </ pre > : null }
440
443
< p > 💿 Hey developer 👋</ p >
441
444
< p >
442
445
You can provide a way better UX than this when your app throws errors by
@@ -645,8 +648,8 @@ export function useMatches() {
645
648
id : match . route . id ,
646
649
pathname,
647
650
params,
648
- data : loaderData [ match . route . id ] ,
649
- handle : match . route . handle ,
651
+ data : loaderData [ match . route . id ] as unknown ,
652
+ handle : match . route . handle as unknown ,
650
653
} ;
651
654
} ) ,
652
655
[ matches , loaderData ]
@@ -656,7 +659,7 @@ export function useMatches() {
656
659
/**
657
660
* Returns the loader data for the nearest ancestor Route loader
658
661
*/
659
- export function useLoaderData ( ) {
662
+ export function useLoaderData ( ) : unknown {
660
663
let state = useDataRouterState ( DataRouterHook . UseLoaderData ) ;
661
664
662
665
let route = React . useContext ( RouteContext ) ;
@@ -674,15 +677,15 @@ export function useLoaderData() {
674
677
/**
675
678
* Returns the loaderData for the given routeId
676
679
*/
677
- export function useRouteLoaderData ( routeId : string ) : any | undefined {
680
+ export function useRouteLoaderData ( routeId : string ) : unknown {
678
681
let state = useDataRouterState ( DataRouterHook . UseRouteLoaderData ) ;
679
682
return state . loaderData [ routeId ] ;
680
683
}
681
684
682
685
/**
683
686
* Returns the action data for the nearest ancestor Route action
684
687
*/
685
- export function useActionData ( ) {
688
+ export function useActionData ( ) : unknown {
686
689
let state = useDataRouterState ( DataRouterHook . UseActionData ) ;
687
690
688
691
let route = React . useContext ( RouteContext ) ;
@@ -696,7 +699,7 @@ export function useActionData() {
696
699
* error or a render error. This is intended to be called from your
697
700
* errorElement to display a proper error message.
698
701
*/
699
- export function useRouteError ( ) {
702
+ export function useRouteError ( ) : unknown {
700
703
let error = React . useContext ( RouteErrorContext ) ;
701
704
let state = useDataRouterState ( DataRouterHook . UseRouteError ) ;
702
705
let route = React . useContext ( RouteContext ) ;
0 commit comments