mirror of
https://github.com/facebook/react.git
synced 2026-02-26 01:15:00 +00:00
Follow up to #28783 and #28786. Since we've changed the implementations of these we can rename them to something a bit more descriptive while we're at it, since anyone depending on them will need to upgrade their code anyway. "react" with no condition: `__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE` "react" with "react-server" condition: `__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE` "react-dom": `__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`
57 lines
1.2 KiB
JavaScript
57 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {ReactNodeList} from 'shared/ReactTypes';
|
|
import type {
|
|
RootType,
|
|
HydrateRootOptions,
|
|
CreateRootOptions,
|
|
} from './src/client/ReactDOMRoot';
|
|
|
|
import {
|
|
createRoot as createRootImpl,
|
|
hydrateRoot as hydrateRootImpl,
|
|
__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE as Internals,
|
|
} from './';
|
|
|
|
export function createRoot(
|
|
container: Element | Document | DocumentFragment,
|
|
options?: CreateRootOptions,
|
|
): RootType {
|
|
if (__DEV__) {
|
|
(Internals: any).usingClientEntryPoint = true;
|
|
}
|
|
try {
|
|
return createRootImpl(container, options);
|
|
} finally {
|
|
if (__DEV__) {
|
|
(Internals: any).usingClientEntryPoint = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
export function hydrateRoot(
|
|
container: Document | Element,
|
|
children: ReactNodeList,
|
|
options?: HydrateRootOptions,
|
|
): RootType {
|
|
if (__DEV__) {
|
|
(Internals: any).usingClientEntryPoint = true;
|
|
}
|
|
try {
|
|
return hydrateRootImpl(container, children, options);
|
|
} finally {
|
|
if (__DEV__) {
|
|
(Internals: any).usingClientEntryPoint = false;
|
|
}
|
|
}
|
|
}
|