From e0a506fac383bbf892ea57b43dc6924b3ec5e452 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Wed, 16 Apr 2025 03:58:58 -0700 Subject: [PATCH] Import React namespace instead of specific types (#50749) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50749 Changelog: [Internal] Reviewed By: huntie Differential Revision: D73088912 fbshipit-source-id: 23e4d530fc3b7fb2a0611ba1721474671ab0b9fd --- .../Libraries/ReactNative/RendererImplementation.js | 11 ++++++----- .../__tests__/__snapshots__/public-api-test.js.snap | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/react-native/Libraries/ReactNative/RendererImplementation.js b/packages/react-native/Libraries/ReactNative/RendererImplementation.js index ee5a80d4fc5..d883a182877 100644 --- a/packages/react-native/Libraries/ReactNative/RendererImplementation.js +++ b/packages/react-native/Libraries/ReactNative/RendererImplementation.js @@ -13,7 +13,6 @@ import type { InternalInstanceHandle, Node, } from '../Renderer/shims/ReactNativeTypes'; -import type {ElementRef, ElementType} from 'react'; import { onCaughtError, @@ -21,6 +20,8 @@ import { onUncaughtError, } from '../../src/private/renderer/errorhandling/ErrorHandlers'; import {type RootTag} from './RootTag'; +import * as React from 'react'; + export function renderElement({ element, rootTag, @@ -58,9 +59,9 @@ export function renderElement({ } } -export function findHostInstance_DEPRECATED( +export function findHostInstance_DEPRECATED( // $FlowFixMe[incompatible-call] - componentOrHandle: ?(ElementRef | number), + componentOrHandle: ?(React.ElementRef | number), ): ?HostInstance { return require('../Renderer/shims/ReactNative').default.findHostInstance_DEPRECATED( // $FlowFixMe[incompatible-call] @@ -68,9 +69,9 @@ export function findHostInstance_DEPRECATED( ); } -export function findNodeHandle( +export function findNodeHandle( // $FlowFixMe[incompatible-call] - componentOrHandle: ?(ElementRef | number), + componentOrHandle: ?(React.ElementRef | number), ): ?number { return require('../Renderer/shims/ReactNative').default.findNodeHandle( // $FlowFixMe[incompatible-call] diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index cf2675ce995..d5e2dfaafa1 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -6749,11 +6749,13 @@ exports[`public API should not change unintentionally Libraries/ReactNative/Rend useFabric: boolean, useConcurrentRoot: boolean, }): void; -declare export function findHostInstance_DEPRECATED( - componentOrHandle: ?(ElementRef | number) +declare export function findHostInstance_DEPRECATED< + TElementType: React.ElementType, +>( + componentOrHandle: ?(React.ElementRef | number) ): ?HostInstance; -declare export function findNodeHandle( - componentOrHandle: ?(ElementRef | number) +declare export function findNodeHandle( + componentOrHandle: ?(React.ElementRef | number) ): ?number; declare export function dispatchCommand( handle: HostInstance,