Created
May 28, 2023 18:18
-
-
Save khg0712/ff3f8afc2f032f22a9eeeda0d624782a 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 | |
// AppContainer에서 RouterContext에 Router 싱글톤 주입하는 코드 | |
// https://github.com/vercel/next.js/blob/v12.3.4/packages/next/client/index.tsx#L296 | |
function AppContainer({ | |
children, | |
}: React.PropsWithChildren<{}>): React.ReactElement { | |
return ( | |
<Container> | |
<RouterContext.Provider value={makePublicRouterInstance(router)}> | |
{/* ... */} | |
</RouterContext.Provider> | |
</Container> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment