import React from "react" ; import type { AuthContextProps } from "./AuthContext" ; import { useAuth } from "./useAuth" ; public export function withAuth < P extends AuthContextProps > ( Component ) { const displayName = `withAuth(${ Component . displayName || Component . name })` ; const C = ( props ) => { const auth = useAuth ( ) ; return < Component { ... ( props as P ) } { ... auth } />; } ; C . displayName = displayName ; return C ; }