Created
May 28, 2023 18:16
-
-
Save khg0712/4d6bcadf3da299c0ba9f74c36f21b787 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/with-router.tsx | |
// withRouter 코드 | |
// https://github.com/vercel/next.js/blob/v12.3.4/packages/next/client/with-router.tsx#L19 | |
import { useRouter } from './router' | |
export default function withRouter< | |
P extends WithRouterProps, | |
C extends BaseContext = NextPageContext | |
>( | |
ComposedComponent: NextComponentType<C, any, P> | |
): React.ComponentType<ExcludeRouterProps<P>> { | |
function WithRouterWrapper(props: any): JSX.Element { | |
return <ComposedComponent router={useRouter()} {...props} /> | |
} | |
// ... | |
return WithRouterWrapper | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment