All files / app/features/profile/hooks useProfileUser.tsx

90% Statements 9/10
0% Branches 0/1
100% Functions 2/2
90% Lines 9/10

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 30 31 32  5x   5x     5x             5x       49x             5x 215x 215x     215x    
import { User } from "proto/api_pb";
import * as React from "react";
 
const ProfileUserContext = React.createContext<User.AsObject>(
  {} as User.AsObject
);
ProfileUserContext.displayName = "ProfileUserContext";
 
interface ProfileUserProviderProps {
  children?: React.ReactNode;
  user: User.AsObject;
}
 
export function ProfileUserProvider({
  children,
  user,
}: ProfileUserProviderProps) {
  return (
    <ProfileUserContext.Provider value={user}>
      {children}
    </ProfileUserContext.Provider>
  );
}
 
export function useProfileUser() {
  const profileUser = React.useContext(ProfileUserContext);
  Iif (profileUser === null) {
    throw new Error("No ProfileUserContext provided!");
  }
  return profileUser;
}