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

🐛 최초 접속 시 렌더링 문제 #26

Merged
merged 2 commits into from
Nov 1, 2023
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: 8 additions & 1 deletion src/app/(root)/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React from 'react'
import Link from 'next/link'
import AppPath from '@/config/appPath'

export default function NotFound() {
return <div>NotFound</div>
return (
<div className="flex flex-row mx-auto my-10">
<span>Not Founded</span>
<Link href={AppPath.home()}>홈페이지로 돌아가기</Link>
</div>
)
}
23 changes: 10 additions & 13 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Suspense } from 'react'
import type { Metadata } from 'next'
import Head from 'next/head'
import Header from '@/components/domain/Header'
import { FetchProvider } from '@/contexts/FetchContext'
import MSWWrapper from '@/contexts/MSWWrapper'
Expand All @@ -11,36 +10,34 @@ import '@/styles/globals.css'
export const metadata: Metadata = {
title: '나비장터',
description: '물물교환 플랫폼 나비장터입니다.',
viewport: 'width=device-width, initial-scale=1.0',
}

export default function RootLayout({
children,
authModal,
}: {
}: Readonly<{
children: React.ReactNode
authModal: React.ReactNode
}) {
}>) {
return (
<html lang="ko">
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
<body>
<FetchProvider>
<TanstackQueryContext>
<MSWWrapper>
<MSWWrapper>
<FetchProvider>
<TanstackQueryContext>
<ThemeProviderContext>
<Suspense>
<Suspense fallback={<div>loading...</div>}>
<div className="centered-content">
<Header isLogin={false} />
{children}
{authModal}
</div>
</Suspense>
</ThemeProviderContext>
</MSWWrapper>
</TanstackQueryContext>
</FetchProvider>
</TanstackQueryContext>
</FetchProvider>
</MSWWrapper>
</body>
</html>
)
Expand Down
4 changes: 1 addition & 3 deletions src/contexts/MSWWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ const MSWComponent = ({ children }: PropsWithChildren) => {
}
}, [mswReady])

if (!mswReady) {
return null
}
if (!mswReady) return null

return <>{children}</>
}
Expand Down
6 changes: 3 additions & 3 deletions src/contexts/ThemeProviderContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const ThemeProviderContext = ({ children }: ThemeProviderContextProps) => {
setMounted(true)
}, [])

return (
<ThemeProvider attribute="data-theme">{mounted && children}</ThemeProvider>
)
if (!mounted) return null

return <ThemeProvider attribute="data-theme">{children}</ThemeProvider>
}

export default ThemeProviderContext