From c613b34020945414d0cae853319b70e08506dbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 10 Sep 2026 17:03:25 -0700 Subject: [PATCH] Remove deprecated Libraries/ReactPrivate forwarding modules (#58452) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/react/react-native/pull/58452 **Cleanup**: The `react-private-interface` entry point (D111231527) now provides the private contract between React and React Native that `Libraries/ReactPrivate/` (deprecated) forwarded to. We can now delete. **Changes** - Delete `Libraries/ReactPrivate/` — `ReactNativePrivateInterface.js`, `ReactNativePrivateInitializeCore.js`, and their `.flow`/`README` files. - Update internal module references to point to source modules. - Update xplat/js references to use new private entry point. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D114055938 fbshipit-source-id: 01f0e6961ddb78d8a39eefc1d749a3deafe01d5f --- packages/eslint-plugin-react-native/utils.js | 4 ---- .../Libraries/Animated/nodes/AnimatedProps.js | 2 +- .../ReactFabricPublicInstance.js | 2 ++ .../Libraries/ReactPrivate/README | 1 - .../ReactNativePrivateInitializeCore.js | 11 ---------- .../ReactNativePrivateInterface.js | 20 ------------------- .../ReactNativePrivateInterface.js.flow | 15 -------------- packages/react-native/ReactNativeApi.d.ts | 7 +++---- packages/react-native/index.js.flow | 2 +- .../ShadowNodeReferenceCounter-itest.js | 2 +- .../__tests__/VirtualView-itest.js | 2 +- .../src/react-private-interface.js | 6 ++---- 12 files changed, 11 insertions(+), 63 deletions(-) delete mode 100644 packages/react-native/Libraries/ReactPrivate/README delete mode 100644 packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js delete mode 100644 packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js delete mode 100644 packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow diff --git a/packages/eslint-plugin-react-native/utils.js b/packages/eslint-plugin-react-native/utils.js index 728cc26d6ab..851592232ed 100644 --- a/packages/eslint-plugin-react-native/utils.js +++ b/packages/eslint-plugin-react-native/utils.js @@ -519,10 +519,6 @@ const publicAPIMapping = { default: null, types: ['ErrorUtils'], }, - 'Libraries/ReactPrivate/ReactNativePrivateInterface': { - default: null, - types: ['PublicRootInstance', 'PublicTextInstance'], - }, }; module.exports = { diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js b/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js index 438b832b5dd..8ea0aeae98f 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js @@ -16,8 +16,8 @@ import type {AnimatedStyleAllowlist} from './AnimatedStyle'; import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper'; import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags'; import {getFabricUIManager} from '../../ReactNative/FabricUIManager'; +import {getNodeFromPublicInstance} from '../../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; import {findNodeHandle} from '../../ReactNative/RendererProxy'; -import {getNodeFromPublicInstance} from '../../ReactPrivate/ReactNativePrivateInterface'; import flattenStyle from '../../StyleSheet/flattenStyle'; import {AnimatedEvent} from '../AnimatedEvent'; import AnimatedNode from './AnimatedNode'; diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js index 1e2c9b54a24..4a4d1298452 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js @@ -55,6 +55,8 @@ export function createPublicTextInstance( return new ReadOnlyText(internalInstanceHandle, ownerDocument); } +export type PublicTextInstance = ReturnType; + export function getNativeTagFromPublicInstance( publicInstance: ReactNativeElement, ): number { diff --git a/packages/react-native/Libraries/ReactPrivate/README b/packages/react-native/Libraries/ReactPrivate/README deleted file mode 100644 index afda34a7043..00000000000 --- a/packages/react-native/Libraries/ReactPrivate/README +++ /dev/null @@ -1 +0,0 @@ -JS modules in this folder are forwarding modules to allow React to require React Native internals. diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js deleted file mode 100644 index 6ec07f7d662..00000000000 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * 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 strict-local - * @format - */ - -import '../Core/InitializeCore'; diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js deleted file mode 100644 index 2cf1eca02e9..00000000000 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * 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 strict-local - * @format - */ - -import typeof {createPublicTextInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; - -export type {PublicRootInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; -export type PublicTextInstance = ReturnType; - -/** - * @deprecated Since 0.88. Use 'react-native/react-private-interface' instead. - */ -// eslint-disable-next-line @react-native/monorepo/no-commonjs-exports -module.exports = require('../../src/react-private-interface'); diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow deleted file mode 100644 index c9b1e0e77c8..00000000000 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +++ /dev/null @@ -1,15 +0,0 @@ -/** - * 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 strict-local - * @format - */ - -/** - * @deprecated Since 0.88. Use 'react-native/react-private-interface' instead. - */ -export type * from '../../src/react-private-interface'; -export * from '../../src/react-private-interface'; diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index fdbb244dd8a..429f8506e44 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<590f18ec6caea33fef591da5d56419f4>> + * @generated SignedSource<> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -1823,7 +1823,6 @@ declare function createPublicTextInstance( internalInstanceHandle: InternalInstanceHandle, ownerDocument: ReactNativeDocument_default, ): ReadOnlyText_default -declare type createPublicTextInstanceT = typeof createPublicTextInstance declare type CursorValue = "auto" | "pointer" declare type DataDetectorTypesType = | "address" @@ -3705,7 +3704,7 @@ declare type ProgressBarAndroidProps = declare type PublicRootInstance = symbol & { __PublicRootInstance__: string } -declare type PublicTextInstance = ReturnType +declare type PublicTextInstance = ReturnType declare interface PushNotification { finish(result: string): void getAlert(): (Object | undefined) | (string | undefined) @@ -5941,7 +5940,7 @@ export { ProgressBarAndroidInstance, // ab545ef1 ProgressBarAndroidProps, // 6484d368 PublicRootInstance, // 8040afd7 - PublicTextInstance, // 6937c7bf + PublicTextInstance, // 16c26204 PushNotificationEventName, // 84e7e150 PushNotificationIOS, // b4d1fe78 PushNotificationPermissions, // c2e7ae4f diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index 51e4a54e055..c6895832c4f 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -497,7 +497,7 @@ export type {ErrorUtils} from './Libraries/vendor/core/ErrorUtils'; export type { PublicRootInstance, PublicTextInstance, -} from './Libraries/ReactPrivate/ReactNativePrivateInterface'; +} from './Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; export type { EventSubscription, diff --git a/packages/react-native/src/private/__tests__/utilities/__tests__/ShadowNodeReferenceCounter-itest.js b/packages/react-native/src/private/__tests__/utilities/__tests__/ShadowNodeReferenceCounter-itest.js index 6b21cd1df75..3553ffdfd43 100644 --- a/packages/react-native/src/private/__tests__/utilities/__tests__/ShadowNodeReferenceCounter-itest.js +++ b/packages/react-native/src/private/__tests__/utilities/__tests__/ShadowNodeReferenceCounter-itest.js @@ -14,7 +14,7 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import type {Node} from '../../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {HostInstance} from 'react-native'; -import {getNodeFromPublicInstance} from '../../../../../Libraries/ReactPrivate/ReactNativePrivateInterface'; +import {getNodeFromPublicInstance} from '../../../../../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; import isUnreachable from '../isUnreachable'; import { createShadowNodeReferenceCounter, diff --git a/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js b/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js index 1f539bb27d2..7ed47b210ad 100644 --- a/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js +++ b/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js @@ -16,7 +16,7 @@ import type {HostInstance} from 'react-native'; import isUnreachable from '../../../__tests__/utilities/isUnreachable'; import {createShadowNodeReferenceCountingRef} from '../../../__tests__/utilities/ShadowNodeReferenceCounter'; -import {getNodeFromPublicInstance} from '../../../../../Libraries/ReactPrivate/ReactNativePrivateInterface'; +import {getNodeFromPublicInstance} from '../../../../../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; import VirtualView, {_logs, VirtualViewMode} from '../VirtualView'; import * as Fantom from '@react-native/fantom'; import nullthrows from 'nullthrows'; diff --git a/packages/react-native/src/react-private-interface.js b/packages/react-native/src/react-private-interface.js index e6f2c9aec7d..1dd6103dc9f 100644 --- a/packages/react-native/src/react-private-interface.js +++ b/packages/react-native/src/react-private-interface.js @@ -14,10 +14,8 @@ // react-native/react-private-interface // // This is a private entry point allowing React to require React Native -// internals (previously, Libaries/ReactNativePrivateInterface.js). -// -// These APIs should ONLY be used by first party React internals and are not -// part of our public API. +// internals. These APIs should ONLY be used by first party React internals and +// are not part of our public API. // // IMPORTANT: Keep this file in sync with react-private-interface.js.flow. // ----------------------------------------------------------------------------