forked from alloc/types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react.d.ts
26 lines (21 loc) · 838 Bytes
/
react.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as React from 'react'
import { ReactElement, MutableRefObject } from 'react'
export type RefProp<T> = MutableRefObject<T | null | undefined>
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34237
export type ElementType<P = any> =
| React.ElementType<P>
| LeafFunctionComponent<P>
// Function component without children
type LeafFunctionComponent<P> = {
(props: P): ReactElement | null
displayName?: string
}
export type ComponentPropsWithRef<
T extends ElementType
> = T extends React.ComponentClass<infer P>
? React.PropsWithoutRef<P> & React.RefAttributes<InstanceType<T>>
: React.PropsWithRef<React.ComponentProps<T>>
// In @types/react, a "children" prop is required by the "FunctionComponent" type.
export type ComponentType<P = {}> =
| React.ComponentClass<P>
| LeafFunctionComponent<P>