Skip to content

Commit

Permalink
Merge pull request #381 from Jaymyong66/refactor/NotFoundPage
Browse files Browse the repository at this point in the history
ErrorBoundary에 NotFound 페이지 적용
  • Loading branch information
Jaymyong66 authored Aug 9, 2024
2 parents c7a4a17 + 08f4de0 commit f697055
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
9 changes: 2 additions & 7 deletions frontend/src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Outlet } from 'react-router-dom';

import { Header } from '@/components';
import { useHeaderHeight } from '@/hooks/utils/useHeaderHeight';
import { NotFoundPage } from '@/pages';
import * as S from './Layout.style';

const Layout = () => {
Expand All @@ -20,13 +21,7 @@ const Layout = () => {
<S.LayoutContainer>
<Header headerRef={headerRef} />
<S.Wrapper>
<ErrorBoundary
fallback={({ error }) => (
<div>
<span>{String(error)}</span>Local Sentry 에러바운더리입니다.
</div>
)}
>
<ErrorBoundary fallback={() => <NotFoundPage />}>
<Outlet />
</ErrorBoundary>
</S.Wrapper>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/NotFoundPage/NotFoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tigger } from '@/assets/images';
import { Button, Flex, Heading, Text } from '@/components';
import { theme } from '@/style/theme';

const ErrorPage = () => {
const NotFoundPage = () => {
const navigate = useNavigate();

return (
Expand Down Expand Up @@ -36,4 +36,4 @@ const ErrorPage = () => {
);
};

export default ErrorPage;
export default NotFoundPage;
1 change: 1 addition & 0 deletions frontend/src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { default as TemplatePage } from './TemplatePage/TemplatePage';
export { default as TemplateUploadPage } from './TemplateUploadPage/TemplateUploadPage';
export { default as SignupPage } from './SignupPage/SignupPage';
export { default as LoginPage } from './LoginPage/LoginPage';
export { default as NotFoundPage } from './NotFoundPage/NotFoundPage';
8 changes: 6 additions & 2 deletions frontend/src/routes/router.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { createBrowserRouter } from 'react-router-dom';

import { Layout } from '@/components';
import { TemplatePage, MyTemplatePage, TemplateUploadPage, SignupPage, LoginPage } from '@/pages';
import { TemplatePage, MyTemplatePage, TemplateUploadPage, SignupPage, LoginPage, NotFoundPage } from '@/pages';
import AuthGuard from './AuthGuard';
import GuestGuard from './GuestGuard';

const router = createBrowserRouter([
{
errorElement: <div>Global Error Element</div>,
errorElement: <NotFoundPage />,
element: <Layout />,
children: [
{
Expand Down Expand Up @@ -50,6 +50,10 @@ const router = createBrowserRouter([
</AuthGuard>
),
},
{
path: '*',
element: <NotFoundPage />,
},
],
},
]);
Expand Down

0 comments on commit f697055

Please sign in to comment.