From 1eddd65b625eab4c64f2865c954fc81d516187a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 2 Dec 2026 06:05:36 -0800 Subject: [PATCH 1/2] Keep Fabric internals out of the public API snapshot (#60475) Summary: ## Context The public `findNodeHandle` export is a direct alias of `ReactFabric.findNodeHandle`. Its inferred `typeof` declaration pulls the whole private Fabric interface into the generated API snapshot, so internal renderer changes appear as changes to the public React Native API. ## Changes Give the alias a self-contained projection of its existing method signature and regenerate the API snapshot without the private Fabric object and its supporting declarations. The projection preserves the type generator's existing method-level nullable-to-undefined convention; a standalone function annotation would otherwise change the generated public nullability. Keep the runtime alias unchanged and preserve the public call signature. Changelog: [Internal] Reviewed By: javache Differential Revision: D135632950 --- .../ReactNative/RendererImplementation.js | 6 +- packages/react-native/ReactNativeApi.d.ts | 70 +++---------------- 2 files changed, 13 insertions(+), 63 deletions(-) diff --git a/packages/react-native/Libraries/ReactNative/RendererImplementation.js b/packages/react-native/Libraries/ReactNative/RendererImplementation.js index cd4a835d7af3..936c268d29f5 100644 --- a/packages/react-native/Libraries/ReactNative/RendererImplementation.js +++ b/packages/react-native/Libraries/ReactNative/RendererImplementation.js @@ -45,7 +45,11 @@ export function renderElement({ export const dispatchCommand = ReactFabric.dispatchCommand; export const findHostInstance_DEPRECATED = ReactFabric.findHostInstance_DEPRECATED; -export const findNodeHandle = ReactFabric.findNodeHandle; +export const findNodeHandle: { + findNodeHandle( + componentOrHandle: ?(React.ElementRef | number), + ): ?number, +}['findNodeHandle'] = ReactFabric.findNodeHandle; export const sendAccessibilityEvent = ReactFabric.sendAccessibilityEvent; export const isChildPublicInstance = ReactFabric.isChildPublicInstance; export const getNodeFromInternalInstanceHandle = diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index 735254dac1c8..912917abde8f 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<> + * @generated SignedSource<> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -59,7 +59,6 @@ declare const $$index: { get VirtualizedSectionList(): AnyVirtualizedSectionList } declare const $$NativeDeviceInfo: typeof NativeModule_default -declare const $$ReactFabric: typeof ReactFabric_default declare const $$resolveAssetSource: typeof resolveAssetSource_default declare const $$ScrollViewContext: typeof ScrollViewContext_default declare const absoluteFill: AbsoluteFillStyle @@ -228,7 +227,11 @@ declare const eventImpl: ( argMapping: ReadonlyArray, config: EventConfig, ) => (...args: Array) => void -declare const findNodeHandle: typeof $$ReactFabric.findNodeHandle +declare const findNodeHandle: { + findNodeHandle( + componentOrHandle: (number | React.ComponentRef) | undefined, + ): number | undefined +}["findNodeHandle"] declare const flatten: typeof $$flattenStyle declare const forkEvent: typeof $$AnimatedImplementation.forkEvent declare const hairlineWidth: number @@ -343,7 +346,6 @@ declare const RCTNetworking_default: { withCredentials: boolean, ): void } -declare let ReactFabric_default: ReactFabricType declare const registerCallableModule: typeof registerCallableModule_default declare const registerCallableModule_default: RegisterCallableModule declare const requireNativeComponent: typeof requireNativeComponent_default @@ -921,7 +923,6 @@ declare type $$AnimatedImplementation = typeof $$AnimatedImplementation declare type $$flattenStyle = typeof $$flattenStyle declare type $$index = typeof $$index declare type $$NativeDeviceInfo = typeof $$NativeDeviceInfo -declare type $$ReactFabric = typeof $$ReactFabric declare type $$resolveAssetSource = typeof $$resolveAssetSource declare type $$ScrollViewContext = typeof $$ScrollViewContext declare class AbortSignal extends EventTarget_default { @@ -3351,9 +3352,6 @@ declare interface NativeUIEvent { readonly detail: number } declare type Networking = typeof Networking -declare type Node = symbol & { - __Node__: string -} declare class NodeList_default implements Iterable, ArrayLike_2 { [index: number]: T readonly length: number @@ -3959,36 +3957,6 @@ declare type RCTNetworkingEventDefinitions = { ] readonly didSendNetworkData: [[number, number, number]] } -declare type ReactFabricType = { - dispatchCommand( - handle: HostInstance, - command: string, - args: Array, - ): void - findHostInstance_DEPRECATED( - componentOrHandle: (number | React.ComponentRef) | undefined, - ): HostInstance | undefined - findNodeHandle( - componentOrHandle: (number | React.ComponentRef) | undefined, - ): number | undefined - getNodeFromInternalInstanceHandle( - internalInstanceHandle: InternalInstanceHandle, - ): Node | undefined - getPublicInstanceFromInternalInstanceHandle( - internalInstanceHandle: InternalInstanceHandle, - ): HostInstance | null | PublicTextInstance - getPublicInstanceFromRootTag(rootTag: number): null | PublicRootInstance - isChildPublicInstance(parent: HostInstance, child: HostInstance): boolean - render( - element: React.JSX.Element, - containerTag: number, - callback: (() => void) | undefined, - concurrentRoot: boolean | undefined, - options: RenderRootOptions | undefined, - ): React.ComponentRef | undefined - sendAccessibilityEvent(handle: HostInstance, eventType: string): void - unmountComponentAtNode(containerTag: number): void -} declare class ReactNativeDocument_default extends ReadOnlyNode_default { get childElementCount(): number get children(): HTMLCollection_default @@ -4175,28 +4143,6 @@ declare type Registry = { runnables: Runnables sections: ReadonlyArray } -declare type RenderRootOptions = { - onCaughtError?: ( - error: unknown, - errorInfo: { - readonly componentStack?: string - readonly errorBoundary?: React.Component - }, - ) => void - onDefaultTransitionIndicator?: () => (() => void) | void - onRecoverableError?: ( - error: unknown, - errorInfo: { - readonly componentStack?: string - }, - ) => void - onUncaughtError?: ( - error: unknown, - errorInfo: { - readonly componentStack?: string - }, - ) => void -} declare type RequestBody = | ArrayBuffer | ArrayBufferView @@ -5908,7 +5854,7 @@ export { AlertOptions, // 8a116d2a AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // 633f77ed + Animated, // 5569381c AnimatedFlatList, // f32979ff AnimatedImage, // 08521177 AnimatedScrollView, // 1b410f55 @@ -6204,7 +6150,7 @@ export { WrapperComponentProvider, // 6ce47ba4 codegenNativeCommands, // 322f3f4e codegenNativeComponent, // 162426af - findNodeHandle, // 93f80214 + findNodeHandle, // fcaaf831 processColor, // 6e877698 registerCallableModule, // 55bda579 requireNativeComponent, // 27104937 From 014c673f2a867d713ebacdacd8d66edd292c7a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 2 Dec 2026 06:05:36 -0800 Subject: [PATCH 2/2] Add flushSync to the Fabric renderer (#38475) Summary: This just adds the definition of flushSync to the generated types, but the actual implementation will land in a different PR shortly. Changelog: [internal] Reviewed By: javache Differential Revision: D135611937 --- .../react-native/Libraries/Renderer/shims/ReactNativeTypes.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js b/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js index cf4aac63d4b4..95abfe4192e4 100644 --- a/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js @@ -7,7 +7,7 @@ * @noformat * @nolint * @flow strict - * @generated SignedSource<> + * @generated SignedSource<> */ import type { @@ -163,6 +163,7 @@ export type ReactFabricType = { options: ?RenderRootOptions, ): ?React.ElementRef, unmountComponentAtNode(containerTag: number): void, + readonly flushSync: ((fn: () => R) => R) & ((fn: void) => void), getNodeFromInternalInstanceHandle( internalInstanceHandle: InternalInstanceHandle, ): ?Node,