-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat(create-board): 게시판 정보 prefetch 추가
related to: #169
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/app/(main)/activity/[semesterName]/[activityId]/boards/[boardId]/create-post/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { | ||
HydrationBoundary, | ||
QueryClient, | ||
dehydrate, | ||
} from '@tanstack/react-query' | ||
|
||
import { boardDetailQuery } from '@/service/data/boards' | ||
|
||
type CreateBoardLayoutParams = { | ||
activityId: string | ||
boardId: string | ||
} | ||
|
||
type CreateBoardLayoutProps = { | ||
children: ReactNode | ||
params: CreateBoardLayoutParams | ||
} | ||
|
||
const CreateBoardLayout = async ({ | ||
children, | ||
params, | ||
}: CreateBoardLayoutProps) => { | ||
const queryClient = new QueryClient() | ||
|
||
await queryClient.prefetchQuery( | ||
boardDetailQuery(Number(params.activityId), Number(params.boardId)), | ||
) | ||
|
||
return ( | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
{children} | ||
</HydrationBoundary> | ||
) | ||
} | ||
|
||
export default CreateBoardLayout |