From 8fdcd0ac9cce491eac1ff13aa06dcc9da0f1167e Mon Sep 17 00:00:00 2001 From: Manan Date: Mon, 11 May 2026 14:14:45 -0700 Subject: [PATCH] fix(ios): use findNodeHandle to register PasteInput on Fabric MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PasteInputIOSComponent reads `textInputRef.current?.__nativeTag` to build the per-instance nativeID it passes to registerTextInput. That property name is from the legacy renderer; under Fabric (RN 0.76+ with new arch enabled) the renderer exposes the tag as `_nativeTag` (single underscore) on the component instance. On Fabric the lookup is undefined, the useEffect bails before calling registerTextInput, and the native module never attaches its paste: swizzle to the underlying UITextView. In __DEV__ this surfaces as the "[PasteInput] Could not get native tag from ref" console warning; in release it is a silent no-op. The Edit Menu / QuickType Paste / long- press Paste all fall through to the default UITextView paste handler, which does nothing for image-only clipboard contents — so to the user it looks like onPaste never fires. Switch to findNodeHandle from react-native, which is the public API and works across both legacy and Fabric (it returns the renderer's internal tag using the correct property name per arch). Repro: RN 0.83.6 + Expo 55.0.16 + RCT_NEW_ARCH_ENABLED=1, mount a , focus it, copy a PNG to the clipboard, tap the system Paste suggestion — onPaste never fires before this change. Fixes #54 --- src/PasteInput.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/PasteInput.tsx b/src/PasteInput.tsx index 12befab..b0d63e6 100644 --- a/src/PasteInput.tsx +++ b/src/PasteInput.tsx @@ -26,7 +26,12 @@ import React, { forwardRef, useImperativeHandle, } from 'react'; -import { Platform, TextInput, NativeEventEmitter } from 'react-native'; +import { + Platform, + TextInput, + NativeEventEmitter, + findNodeHandle, +} from 'react-native'; import type { PastedFile, PasteInputProps, @@ -78,9 +83,14 @@ function PasteInputIOSComponent( // Register/unregister with native module on mount/unmount useEffect(() => { - // Get the native tag from the ref's internal __nativeTag property - // @ts-ignore - __nativeTag is an internal property - const nativeTag = textInputRef.current?.__nativeTag; + // Use findNodeHandle so we work across both legacy and Fabric. Reading + // `__nativeTag` directly returns undefined on RN 0.76+/Fabric — the + // renderer exposes the tag as `_nativeTag` (single underscore) on the + // Fabric instance — which silently breaks paste interception because + // the input is never registered with the native module. See #54. + const nativeTag = textInputRef.current + ? findNodeHandle(textInputRef.current) + : null; if (!nativeTag) { if (__DEV__) {