@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
18 lines (17 loc) • 842 B
TypeScript
import type { ComponentType } from 'react';
/**
* Extracts only React components from an input object and creates a new object.
* Filters out non-component values using component type checking.
* @typeParam Input - The input object type
* @typeParam Output - The output object type
* @param dictionary - An object containing React components and other values
* @returns A new object containing only React components
* @example
* const components = remainOnlyReactComponent({
* Button: ButtonComponent,
* Icon: IconComponent,
* helper: helperFunction, // Not a component, will be excluded
* });
* // Result: { Button: ButtonComponent, Icon: IconComponent }
*/
export declare const remainOnlyReactComponent: <Input extends Record<string, unknown>, Output extends Record<string, ComponentType>>(dictionary: Input) => Output;