From 2c31c279a1e7d1edd3f10ebfaa73c413c6561f2b Mon Sep 17 00:00:00 2001 From: enes Date: Tue, 12 Nov 2024 14:22:54 +0100 Subject: [PATCH] refactor(404): more generic error page --- src/pages/404.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 1c53760..d3e5a77 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -1,17 +1,27 @@ -import { Link } from 'react-router-dom' +import { Link, useRouteError } from 'react-router-dom' import { appRoutes } from 'routes' -export const NotFoundPage = () => { +interface NotFoundPageProps { + title: string + message: string +} + +export const NotFoundPage = ({ + title = 'Page not found', + message = "The page you're attempting to visit doesn't exist" +}: Partial) => { + const error = useRouteError() as Partial + return (
-

Page not found

+

{error?.title || title}

-

The page you're attempting to visit doesn't exist

+

{error?.message || message}