UNPKG

1.75 kBTypeScriptView Raw
1import * as React from "react";
2/**
3 * Returns true if `node` is null/undefined, false, empty string, or an array
4 * composed of those. If `node` is an array, only one level of the array is
5 * checked, for performance reasons.
6 */
7export declare function isReactNodeEmpty(node?: React.ReactNode, skipArray?: boolean): boolean;
8/**
9 * Converts a React node to an element. Non-empty strings, numbers, and Fragments will be wrapped in given tag name;
10 * empty strings and booleans will be discarded.
11 *
12 * @param child the React node to convert
13 * @param tagName the HTML tag name to use when a wrapper element is needed
14 * @param props additional props to spread onto the element, if any. If the child is a React element and this argument
15 * is defined, the child will be cloned and these props will be merged in.
16 */
17export declare function ensureElement(child: React.ReactNode | undefined, tagName?: keyof React.JSX.IntrinsicElements, props?: React.HTMLProps<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
18export declare function isReactElement<T = any>(child: React.ReactNode): child is React.ReactElement<T>;
19/**
20 * Returns true if the given JSX element matches the given component type.
21 *
22 * NOTE: This function only checks equality of `displayName` for performance and
23 * to tolerate multiple minor versions of a component being included in one
24 * application bundle.
25 *
26 * @param element JSX element in question
27 * @param ComponentType desired component type of element
28 */
29export declare function isElementOfType<P = {}>(element: any, ComponentType: React.ComponentType<P>): element is React.ReactElement<P>;
30export declare function isReact18OrHigher(): boolean;