Skip to content

Commit 0f5ee60

Browse files
committed
Add defaultNotFoundComponent to router
1 parent a885030 commit 0f5ee60

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/social-web/router/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type { AnyRoute, AnyRouter, RouteComponent } from '@tanstack/react-router
3131
*/
3232
import { useState, useEffect } from '@wordpress/element';
3333
import { Spinner } from '@wordpress/components';
34+
import { __ } from '@wordpress/i18n';
3435

3536
/**
3637
* Internal dependencies
@@ -48,6 +49,13 @@ export { Outlet };
4849
// Create Link component for navigation
4950
export const Link = createLink( { defaultPreload: 'intent' } );
5051

52+
/**
53+
* Not found component displayed when no route matches.
54+
*/
55+
function NotFoundComponent() {
56+
return <div style={ { padding: '20px', textAlign: 'center' } }>{ __( 'Page not found', 'activitypub' ) }</div>;
57+
}
58+
5159
/**
5260
* Creates a TanStack route from a Route definition.
5361
*
@@ -197,6 +205,7 @@ export default function Router( { routes, rootComponent }: RouterProps ) {
197205
history,
198206
routeTree,
199207
defaultPreload: 'intent',
208+
defaultNotFoundComponent: NotFoundComponent,
200209
} as never );
201210
setRouter( newRouter );
202211
}

0 commit comments

Comments
 (0)