All files / Rindu/hooks useCustomContext.ts

85.71% Statements 6/7
0% Branches 0/1
100% Functions 1/1
85.71% Lines 6/7

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 1520x   20x   676x     676x 676x       676x    
import { Context, useContext } from "react";
 
import { ContextError } from "utils";
 
export function useCustomContext<T>(
  Context: Context<T | undefined>
): NonNullable<T> {
  const context = useContext(Context);
  Iif (!context) {
    throw new ContextError(Context);
  }
 
  return context;
}