From 0491d21f0acccc5d6452fab46a45726de983a3fc Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Mon, 15 Jan 2024 09:47:05 -0800 Subject: [PATCH] fix[getInternalInstanceHandleFromPublicInstance]: make it backwards compatible with previous Fabric implementation Summary: Changelog: [Internal] Currently, OSS versions ofReactFabric and ReactNativeRenderer artifacts are ~2 years behind the FB version. Fabric host components store internal instance in __internalInstanceHandle field, previously they have been storing it in the field with the same name, but with one underscore in prefix: https://www.internalfb.com/code/fbsource/[79c52d10beb6]/xplat/js/react-native-github/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js?lines=5151 Once these artifacts will be synced, the implementation will use __internalInstanceHandle field, so we can safely remove the branch with a single underscore prefix. Differential Revision: D52697886 fbshipit-source-id: af2bacfc8bf38f45ddc950d43615fc2f02476c3a --- .../ReactFabricPublicInstance/ReactFabricPublicInstance.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js index 2502bab8692302..54d8368ff2b8c6 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js @@ -88,5 +88,12 @@ export function getNodeFromPublicInstance( export function getInternalInstanceHandleFromPublicInstance( publicInstance: ReactFabricHostComponent | ReactNativeElement, ): InternalInstanceHandle { + // TODO(T174762768): Remove this once OSS versions of renderers will be synced. + // $FlowExpectedError[prop-missing] Keeping this for backwards-compatibility with the renderers versions in open source. + if (publicInstance._internalInstanceHandle != null) { + // $FlowExpectedError[incompatible-return] Keeping this for backwards-compatibility with the renderers versions in open source. + return publicInstance._internalInstanceHandle; + } + return publicInstance.__internalInstanceHandle; }