Skip to content

Commit 82b1485

Browse files
rubennortefacebook-github-bot
authored andcommitted
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
1 parent 6aa3991 commit 82b1485

2 files changed

Lines changed: 13 additions & 63 deletions

File tree

‎packages/react-native/Libraries/ReactNative/RendererImplementation.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export function renderElement({
4545
export const dispatchCommand = ReactFabric.dispatchCommand;
4646
export const findHostInstance_DEPRECATED =
4747
ReactFabric.findHostInstance_DEPRECATED;
48-
export const findNodeHandle = ReactFabric.findNodeHandle;
48+
export const findNodeHandle: {
49+
findNodeHandle<TElementType extends React.ElementType>(
50+
componentOrHandle: ?(React.ElementRef<TElementType> | number),
51+
): ?number,
52+
}['findNodeHandle'] = ReactFabric.findNodeHandle;
4953
export const sendAccessibilityEvent = ReactFabric.sendAccessibilityEvent;
5054
export const isChildPublicInstance = ReactFabric.isChildPublicInstance;
5155
export const getNodeFromInternalInstanceHandle =

‎packages/react-native/ReactNativeApi.d.ts‎

Lines changed: 8 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d85687fceb0705d7e07b3a0b4529a17f>>
7+
* @generated SignedSource<<fee829cb43f2a2ab85398910c6659b23>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -59,7 +59,6 @@ declare const $$index: {
5959
get VirtualizedSectionList(): AnyVirtualizedSectionList
6060
}
6161
declare const $$NativeDeviceInfo: typeof NativeModule_default
62-
declare const $$ReactFabric: typeof ReactFabric_default
6362
declare const $$resolveAssetSource: typeof resolveAssetSource_default
6463
declare const $$ScrollViewContext: typeof ScrollViewContext_default
6564
declare const absoluteFill: AbsoluteFillStyle
@@ -228,7 +227,11 @@ declare const eventImpl: <T>(
228227
argMapping: ReadonlyArray<Mapping | null | undefined>,
229228
config: EventConfig<T>,
230229
) => (...args: Array<any>) => void
231-
declare const findNodeHandle: typeof $$ReactFabric.findNodeHandle
230+
declare const findNodeHandle: {
231+
findNodeHandle<TElementType extends React.ElementType>(
232+
componentOrHandle: (number | React.ComponentRef<TElementType>) | undefined,
233+
): number | undefined
234+
}["findNodeHandle"]
232235
declare const flatten: typeof $$flattenStyle
233236
declare const forkEvent: typeof $$AnimatedImplementation.forkEvent
234237
declare const hairlineWidth: number
@@ -343,7 +346,6 @@ declare const RCTNetworking_default: {
343346
withCredentials: boolean,
344347
): void
345348
}
346-
declare let ReactFabric_default: ReactFabricType
347349
declare const registerCallableModule: typeof registerCallableModule_default
348350
declare const registerCallableModule_default: RegisterCallableModule
349351
declare const requireNativeComponent: typeof requireNativeComponent_default
@@ -921,7 +923,6 @@ declare type $$AnimatedImplementation = typeof $$AnimatedImplementation
921923
declare type $$flattenStyle = typeof $$flattenStyle
922924
declare type $$index = typeof $$index
923925
declare type $$NativeDeviceInfo = typeof $$NativeDeviceInfo
924-
declare type $$ReactFabric = typeof $$ReactFabric
925926
declare type $$resolveAssetSource = typeof $$resolveAssetSource
926927
declare type $$ScrollViewContext = typeof $$ScrollViewContext
927928
declare class AbortSignal extends EventTarget_default {
@@ -3351,9 +3352,6 @@ declare interface NativeUIEvent {
33513352
readonly detail: number
33523353
}
33533354
declare type Networking = typeof Networking
3354-
declare type Node = symbol & {
3355-
__Node__: string
3356-
}
33573355
declare class NodeList_default<T> implements Iterable<T>, ArrayLike_2<T> {
33583356
[index: number]: T
33593357
readonly length: number
@@ -3959,36 +3957,6 @@ declare type RCTNetworkingEventDefinitions = {
39593957
]
39603958
readonly didSendNetworkData: [[number, number, number]]
39613959
}
3962-
declare type ReactFabricType = {
3963-
dispatchCommand(
3964-
handle: HostInstance,
3965-
command: string,
3966-
args: Array<unknown>,
3967-
): void
3968-
findHostInstance_DEPRECATED<TElementType extends React.ElementType>(
3969-
componentOrHandle: (number | React.ComponentRef<TElementType>) | undefined,
3970-
): HostInstance | undefined
3971-
findNodeHandle<TElementType extends React.ElementType>(
3972-
componentOrHandle: (number | React.ComponentRef<TElementType>) | undefined,
3973-
): number | undefined
3974-
getNodeFromInternalInstanceHandle(
3975-
internalInstanceHandle: InternalInstanceHandle,
3976-
): Node | undefined
3977-
getPublicInstanceFromInternalInstanceHandle(
3978-
internalInstanceHandle: InternalInstanceHandle,
3979-
): HostInstance | null | PublicTextInstance
3980-
getPublicInstanceFromRootTag(rootTag: number): null | PublicRootInstance
3981-
isChildPublicInstance(parent: HostInstance, child: HostInstance): boolean
3982-
render(
3983-
element: React.JSX.Element,
3984-
containerTag: number,
3985-
callback: (() => void) | undefined,
3986-
concurrentRoot: boolean | undefined,
3987-
options: RenderRootOptions | undefined,
3988-
): React.ComponentRef<React.ElementType> | undefined
3989-
sendAccessibilityEvent(handle: HostInstance, eventType: string): void
3990-
unmountComponentAtNode(containerTag: number): void
3991-
}
39923960
declare class ReactNativeDocument_default extends ReadOnlyNode_default {
39933961
get childElementCount(): number
39943962
get children(): HTMLCollection_default<ReadOnlyElement_default>
@@ -4175,28 +4143,6 @@ declare type Registry = {
41754143
runnables: Runnables
41764144
sections: ReadonlyArray<string>
41774145
}
4178-
declare type RenderRootOptions = {
4179-
onCaughtError?: (
4180-
error: unknown,
4181-
errorInfo: {
4182-
readonly componentStack?: string
4183-
readonly errorBoundary?: React.Component<any, any>
4184-
},
4185-
) => void
4186-
onDefaultTransitionIndicator?: () => (() => void) | void
4187-
onRecoverableError?: (
4188-
error: unknown,
4189-
errorInfo: {
4190-
readonly componentStack?: string
4191-
},
4192-
) => void
4193-
onUncaughtError?: (
4194-
error: unknown,
4195-
errorInfo: {
4196-
readonly componentStack?: string
4197-
},
4198-
) => void
4199-
}
42004146
declare type RequestBody =
42014147
| ArrayBuffer
42024148
| ArrayBufferView
@@ -5908,7 +5854,7 @@ export {
59085854
AlertOptions, // 8a116d2a
59095855
AlertType, // 5ab91217
59105856
AndroidKeyboardEvent, // e03becc8
5911-
Animated, // 633f77ed
5857+
Animated, // 5569381c
59125858
AnimatedFlatList, // f32979ff
59135859
AnimatedImage, // 08521177
59145860
AnimatedScrollView, // 1b410f55
@@ -6204,7 +6150,7 @@ export {
62046150
WrapperComponentProvider, // 6ce47ba4
62056151
codegenNativeCommands, // 322f3f4e
62066152
codegenNativeComponent, // 162426af
6207-
findNodeHandle, // 93f80214
6153+
findNodeHandle, // fcaaf831
62086154
processColor, // 6e877698
62096155
registerCallableModule, // 55bda579
62106156
requireNativeComponent, // 27104937

0 commit comments

Comments
 (0)