UNPKG

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