Created
May 28, 2023 18:17
-
-
Save khg0712/7d28576e386448adc5f1d743c5f4a09f to your computer and use it in GitHub Desktop.
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
// packages/next/client/index.ts | |
// Router 싱글톤을 저장하는 전역 객체 | |
// https://github.com/vercel/next.js/blob/v12.3.4/packages/next/client/index.tsx#L67 | |
export let router: Router | |
// hydrate 함수에서 Router 싱글톤이 초기화(createRouter)되는 코드 호출 | |
// https://github.com/vercel/next.js/blob/v12.3.4/packages/next/client/index.tsx#L863 | |
export async function hydrate(opts?: { beforeRender?: () => Promise<void> }) { | |
// ... | |
// 전역 객체 초기화 | |
router = createRouter(initialData.page, initialData.query, asPath, { | |
// ... | |
}) | |
// ... | |
// router 초기화 이후에 Next.js App render | |
render(renderCtx) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment