Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import { UserDetails } from "proto/admin_pb"; import * as React from "react"; const ModUserDetailsContext = React.createContext<UserDetails.AsObject>( {} as UserDetails.AsObject, ); ModUserDetailsContext.displayName = "ModUserDetailsContext"; interface ModUserDetailsProps { children?: React.ReactNode; userDetails: UserDetails.AsObject; } export function ModUserDetails({ children, userDetails }: ModUserDetailsProps) { return ( <ModUserDetailsContext.Provider value={userDetails}> {children} </ModUserDetailsContext.Provider> ); } export function useModUserDetails() { const modUserDetails = React.useContext(ModUserDetailsContext); Iif (modUserDetails === null) { throw new Error("No ModUserDetailsContext provided!"); } return modUserDetails; } |