Skip to content

Commit 4868573

Browse files
committed
Fix error routes for 404 pages
1 parent c1a076f commit 4868573

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

src/routes/ErrorRoutes.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
import React, { lazy, Suspense } from 'react';
21
import { Route, Switch } from 'react-router-dom';
3-
import { Loading } from 'src/components/Loading';
4-
const NotFoundPage = lazy(() => import('src/pages/ErrorPages/404Pages'));
2+
import { NotFoundPage } from 'src/pages/ErrorPages/404Pages';
53
export const ErrorRoutes = () => {
64
return (
75
<Switch>
8-
<Route
9-
component={() => (
10-
<Suspense fallback={<Loading />}>
11-
<NotFoundPage />
12-
</Suspense>
13-
)}
14-
/>
6+
<Route component={NotFoundPage} />;
157
</Switch>
168
);
179
};

src/routes/ProductRoutes.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { Switch } from 'react-router-dom';
33
import { PATH } from 'src/constants/paths';
44
import { Loading } from 'src/components/Loading';
55
import { AuthenticatedGuard } from 'src/guards/AuthenticatedGuard';
6+
import { ErrorRoutes } from './ErrorRoutes';
67
const ProductList = lazy(
78
() => import('src/pages/ProductPages/ProductListPage'),
89
);
910
const ProductItem = lazy(
1011
() => import('src/pages/ProductPages/ProductItemPage'),
1112
);
1213

13-
export const AuthRoutes = () => {
14+
export const ProductRoutes = () => {
1415
return (
1516
<Switch>
1617
<AuthenticatedGuard
@@ -24,13 +25,14 @@ export const AuthRoutes = () => {
2425
/>
2526
<AuthenticatedGuard
2627
exact
27-
path="/products/:id"
28+
path={PATH.PRODUCTS + '/:id'}
2829
component={() => (
2930
<Suspense fallback={<Loading />}>
3031
<ProductItem />
3132
</Suspense>
3233
)}
3334
/>
35+
<ErrorRoutes />
3436
</Switch>
3537
);
3638
};

src/routes/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import React from 'react';
22
import { BrowserRouter } from 'react-router-dom';
33
import { StaticPageRoutes } from './StaticPageRoutes';
44
import { AuthRoutes } from './AuthRoutes';
5-
import { ErrorRoutes } from './ErrorRoutes';
5+
import { ProductRoutes } from './ProductRoutes';
66

77
export const Routes = () => {
88
return (
99
<BrowserRouter>
1010
<StaticPageRoutes />
1111
<AuthRoutes />
12-
<ErrorRoutes />
12+
<ProductRoutes />
1313
</BrowserRouter>
1414
);
1515
};

0 commit comments

Comments
 (0)