UNPKG

4.82 kBTypeScriptView Raw
1// NOTE: Users of the `experimental` builds of React should add a reference
2// to 'react-dom/experimental' in their project. See experimental.d.ts's top comment
3// for reference and documentation on how exactly to do it.
4
5export as namespace ReactDOM;
6
7import {
8 CElement,
9 Component,
10 ComponentState,
11 DOMAttributes,
12 DOMElement,
13 FunctionComponentElement,
14 ReactElement,
15 ReactInstance,
16 ReactNode,
17 ReactPortal,
18} from "react";
19
20/**
21 * @deprecated See https://react.dev/reference/react-dom/findDOMNode#alternatives
22 */
23export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
24/**
25 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
26 */
27export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
28
29export function createPortal(
30 children: ReactNode,
31 container: Element | DocumentFragment,
32 key?: null | string,
33): ReactPortal;
34
35export const version: string;
36/**
37 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
38 */
39export const render: Renderer;
40/**
41 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
42 */
43export const hydrate: Renderer;
44
45export function flushSync<R>(fn: () => R): R;
46
47export function unstable_batchedUpdates<A, R>(callback: (a: A) => R, a: A): R;
48export function unstable_batchedUpdates<R>(callback: () => R): R;
49
50/**
51 * @deprecated
52 */
53export function unstable_renderSubtreeIntoContainer<T extends Element>(
54 parentComponent: Component<any>,
55 element: DOMElement<DOMAttributes<T>, T>,
56 container: Element,
57 callback?: (element: T) => any,
58): T;
59/**
60 * @deprecated
61 */
62export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
63 parentComponent: Component<any>,
64 element: CElement<P, T>,
65 container: Element,
66 callback?: (component: T) => any,
67): T;
68/**
69 * @deprecated
70 */
71export function unstable_renderSubtreeIntoContainer<P>(
72 parentComponent: Component<any>,
73 element: ReactElement<P>,
74 container: Element,
75 callback?: (component?: Component<P, ComponentState> | Element) => any,
76 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
77): Component<P, ComponentState> | Element | void;
78
79export type Container = Element | Document | DocumentFragment;
80
81export interface Renderer {
82 // Deprecated(render): The return value is deprecated.
83 // In future releases the render function's return type will be void.
84
85 /**
86 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
87 */
88 <T extends Element>(
89 element: DOMElement<DOMAttributes<T>, T>,
90 container: Container | null,
91 callback?: () => void,
92 ): T;
93
94 /**
95 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
96 */
97 (
98 element: Array<DOMElement<DOMAttributes<any>, any>>,
99 container: Container | null,
100 callback?: () => void,
101 ): Element;
102
103 /**
104 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
105 */
106 (
107 element: FunctionComponentElement<any> | Array<FunctionComponentElement<any>>,
108 container: Container | null,
109 callback?: () => void,
110 ): void;
111
112 /**
113 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
114 */
115 <P, T extends Component<P, ComponentState>>(
116 element: CElement<P, T>,
117 container: Container | null,
118 callback?: () => void,
119 ): T;
120
121 /**
122 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
123 */
124 (
125 element: Array<CElement<any, Component<any, ComponentState>>>,
126 container: Container | null,
127 callback?: () => void,
128 ): Component<any, ComponentState>;
129
130 /**
131 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
132 */
133 <P>(
134 element: ReactElement<P>,
135 container: Container | null,
136 callback?: () => void,
137 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
138 ): Component<P, ComponentState> | Element | void;
139
140 /**
141 * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
142 */
143 (
144 element: ReactElement[],
145 container: Container | null,
146 callback?: () => void,
147 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
148 ): Component<any, ComponentState> | Element | void;
149}