@winglet/react-utils
Version:
React utility library providing custom hooks, higher-order components (HOCs), and utility functions to enhance React application development with improved reusability and functionality
22 lines (21 loc) • 855 B
TypeScript
import { type ComponentType, type ReactNode } from 'react';
type ReactComponent<P> = ReactNode | ComponentType<P>;
/**
* Appropriately renders ReactNode, component types, or component instances.
* Handles different input types and returns the appropriate rendered output.
* @typeParam P - The component props type
* @param Component - The ReactNode or component to render
* @param props - Props to pass to the component
* @returns The rendered ReactNode or null
* @example
* // Returns ReactElement as-is
* renderComponent(<div>Content</div>)
*
* // Instantiates component type and returns it
* renderComponent(MyComponent, { prop1: 'value1' })
*
* // Returns null for invalid values
* renderComponent(undefined)
*/
export declare const renderComponent: <P extends object>(Component: ReactComponent<P>, props?: P) => ReactNode;
export {};