How to understand ‘JSXElementConstructor<any> = string’?

Viewed 14

In react, the definition of type ‘ReactElement’ is:

interface ReactElement<P = any, T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>> {
    type: T;
    props: P;
    key: Key | null;
}

But I cannot understand what ‘JSXElementConstructor = string’ means.

The type of JSXElementConstructor is:

type JSXElementConstructor<P> =
    | ((props: P) => ReactElement<any, any> | null)
    | (new (props: P) => Component<any, any>);
1 Answers

This is the definition of T : T extends string | JSXElementConstructor<any> = string.

T here can be either string or JSXElementConstructor<any> and the default value is string.

Related