UNPKG

1.58 kBTypeScriptView Raw
1/**
2 * WARNING: This entrypoint is only available starting with `react-dom@18.0.0-rc.1`
3 */
4
5// See https://github.com/facebook/react/blob/main/packages/react-dom/client.js to see how the exports are declared,
6
7import React = require("react");
8export interface HydrationOptions {
9 /**
10 * Prefix for `useId`.
11 */
12 identifierPrefix?: string;
13 onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
14}
15
16export interface RootOptions {
17 /**
18 * Prefix for `useId`.
19 */
20 identifierPrefix?: string;
21 onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
22}
23
24export interface ErrorInfo {
25 digest?: string;
26 componentStack?: string;
27}
28
29export interface Root {
30 render(children: React.ReactNode): void;
31 unmount(): void;
32}
33
34/**
35 * Replaces `ReactDOM.render` when the `.render` method is called and enables Concurrent Mode.
36 *
37 * @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
38 */
39export function createRoot(container: Element | DocumentFragment, options?: RootOptions): Root;
40
41/**
42 * Same as `createRoot()`, but is used to hydrate a container whose HTML contents were rendered by ReactDOMServer.
43 *
44 * React will attempt to attach event listeners to the existing markup.
45 *
46 * **Example Usage**
47 *
48 * ```jsx
49 * hydrateRoot(document.querySelector('#root'), <App />)
50 * ```
51 *
52 * @see https://reactjs.org/docs/react-dom-client.html#hydrateroot
53 */
54export function hydrateRoot(
55 container: Element | Document,
56 initialChildren: React.ReactNode,
57 options?: HydrationOptions,
58): Root;