UNPKG

3.71 kBTypeScriptView Raw
1// Type definitions for React (react-dom) 17.0
2// Project: https://reactjs.org
3// Definitions by: Asana <https://asana.com>
4// AssureSign <http://www.assuresign.com>
5// Microsoft <https://microsoft.com>
6// MartynasZilinskas <https://github.com/MartynasZilinskas>
7// Josh Rutherford <https://github.com/theruther4d>
8// Jessica Franco <https://github.com/Jessidhia>
9// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10// TypeScript Version: 2.8
11
12// NOTE: Users of the `experimental` builds of React should add a reference
13// to 'react-dom/experimental' in their project. See experimental.d.ts's top comment
14// for reference and documentation on how exactly to do it.
15
16export as namespace ReactDOM;
17
18import {
19 ReactInstance, Component, ComponentState,
20 ReactElement, SFCElement, CElement,
21 DOMAttributes, DOMElement, ReactNode, ReactPortal
22} from 'react';
23
24export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
25export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
26
27export function createPortal(children: ReactNode, container: Element, key?: null | string): ReactPortal;
28
29export const version: string;
30export const render: Renderer;
31export const hydrate: Renderer;
32
33export function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
34export function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
35export function unstable_batchedUpdates(callback: () => any): void;
36
37export function unstable_renderSubtreeIntoContainer<T extends Element>(
38 parentComponent: Component<any>,
39 element: DOMElement<DOMAttributes<T>, T>,
40 container: Element,
41 callback?: (element: T) => any): T;
42export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
43 parentComponent: Component<any>,
44 element: CElement<P, T>,
45 container: Element,
46 callback?: (component: T) => any): T;
47export function unstable_renderSubtreeIntoContainer<P>(
48 parentComponent: Component<any>,
49 element: ReactElement<P>,
50 container: Element,
51 callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
52
53export interface Renderer {
54 // Deprecated(render): The return value is deprecated.
55 // In future releases the render function's return type will be void.
56
57 <T extends Element>(
58 element: DOMElement<DOMAttributes<T>, T>,
59 container: Element | DocumentFragment | null,
60 callback?: () => void
61 ): T;
62
63 (
64 element: Array<DOMElement<DOMAttributes<any>, any>>,
65 container: Element | DocumentFragment | null,
66 callback?: () => void
67 ): Element;
68
69 (
70 element: SFCElement<any> | Array<SFCElement<any>>,
71 container: Element | DocumentFragment | null,
72 callback?: () => void
73 ): void;
74
75 <P, T extends Component<P, ComponentState>>(
76 element: CElement<P, T>,
77 container: Element | DocumentFragment | null,
78 callback?: () => void
79 ): T;
80
81 (
82 element: Array<CElement<any, Component<any, ComponentState>>>,
83 container: Element | DocumentFragment | null,
84 callback?: () => void
85 ): Component<any, ComponentState>;
86
87 <P>(
88 element: ReactElement<P>,
89 container: Element | DocumentFragment | null,
90 callback?: () => void
91 ): Component<P, ComponentState> | Element | void;
92
93 (
94 element: ReactElement[],
95 container: Element | DocumentFragment | null,
96 callback?: () => void
97 ): Component<any, ComponentState> | Element | void;
98}