Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorBoundary에 NotFound 페이지 적용 #381

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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