mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
24 lines
587 B
TypeScript
24 lines
587 B
TypeScript
import { SessionProvider } from 'next-auth/react'
|
|
import Auth from '../components/auth'
|
|
|
|
// This is the HOC
|
|
function withAuth(WrappedComponent: React.FunctionComponent) {
|
|
// Return a new component
|
|
function withAuth({ session, ...pageProps }) {
|
|
// Render the WrappedComponent with additional props
|
|
return (
|
|
<SessionProvider session={session}>
|
|
<Auth>
|
|
<WrappedComponent {...pageProps} />
|
|
</Auth>
|
|
</SessionProvider>
|
|
)
|
|
}
|
|
|
|
withAuth.displayName = `withAuth(${WrappedComponent.displayName}`
|
|
|
|
return withAuth
|
|
}
|
|
|
|
export default withAuth
|