Add ErrorPage component to handle route errors
This commit is contained in:
parent
7e45f6c429
commit
0b797a8c58
24
src/pages/ErrorPage.jsx
Normal file
24
src/pages/ErrorPage.jsx
Normal file
@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { useRouteError, isRouteErrorResponse } from 'react-router-dom';
|
||||
|
||||
const ErrorPage =() =>{
|
||||
const error = useRouteError();
|
||||
console.error(error);
|
||||
|
||||
if (isRouteErrorResponse(error)) {
|
||||
return (
|
||||
<div>
|
||||
<h1>{error.status}</h1>
|
||||
<p>{error.statusText}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Something went wrong.</h1>
|
||||
<p>{error?.message || 'Unknown error occurred'}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default ErrorPage
|
@ -30,7 +30,7 @@ import MasterPage from "../pages/master/MasterPage";
|
||||
import Support from "../pages/support/Support";
|
||||
import Documentation from "../pages/support/Documentation";
|
||||
import Connect from "../pages/support/Connect";
|
||||
import { ErrorPage } from "../pages/support/ErrorPage";
|
||||
import ErrorPage from "../pages/ErrorPage";
|
||||
import LegalInfoCard from "../pages/TermsAndConditions/LegalInfoCard";
|
||||
|
||||
// Protected Route Wrapper
|
||||
@ -51,6 +51,7 @@ const router = createBrowserRouter(
|
||||
},
|
||||
{
|
||||
element: <ProtectedRoute />,
|
||||
errorElement:<ErrorPage/>,
|
||||
children: [
|
||||
{
|
||||
element: <HomeLayout />,
|
||||
|
Loading…
x
Reference in New Issue
Block a user