All files / Rindu/utils getElementProps.ts

85.71% Statements 6/7
66.66% Branches 2/3
100% Functions 2/2
83.33% Lines 5/6

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            45x 14x     45x     14x     14x    
import { JSXElementConstructor, ReactElement, ReactNode } from "react";
 
type ElementProps = {
  children?: ReactNode;
} & Record<string, unknown>;
 
const isElementProps = (props: unknown): props is ElementProps => {
  return typeof props === "object" && props !== null;
};
 
export const getElementProps = (
  child: ReactElement<unknown, string | JSXElementConstructor<any>>
): ElementProps => {
  Iif (!isElementProps(child.props)) {
    return { children: undefined };
  }
  return child.props;
};