Skip to content

v2 paste interception silently bails on RN 0.76+ Fabric (uses __nativeTag which is undefined) #54

@manan19

Description

@manan19

Summary

On v2.0.0 / v2.0.1, the iOS paste interception silently fails to register on RN 0.76+ with the New Architecture (Fabric) enabled. The Edit Menu / QuickType "Paste" / long-press → Paste actions fall through to the default UITextView paste handler, which does nothing for image-only clipboard contents — making it look like nothing happens on paste.

Root cause

PasteInputIOSComponent reads the React Native tag via the __nativeTag property (double underscore):

// src/PasteInput.tsx
const nativeTag = textInputRef.current?.__nativeTag;

if (!nativeTag) {
  if (__DEV__) {
    console.warn('[PasteInput] Could not get native tag from ref');
  }
  return;
}

That property name is from the legacy renderer. Under Fabric (RN ≥ 0.76 with RCT_NEW_ARCH_ENABLED=1), the renderer exposes the tag as _nativeTag (single underscore) on the component instance — see e.g. react-native@0.83.6 Libraries/Renderer/implementations/ReactNativeRenderer-prod.js line ~1372:

var tag = inst._nativeTag;

So on Fabric textInputRef.current?.__nativeTag is undefined, the useEffect bails before calling NativePasteInputModule.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 builds it's a silent no-op.

Repro

  • RN ≥ 0.76 with new arch on (RCT_NEW_ARCH_ENABLED=1)
  • v2.0.0 or v2.0.1 installed
  • Mount a <PasteInput onPaste={...} /> and focus it
  • Copy an image to the clipboard (host macOS → iOS Simulator works; public.png on the pasteboard)
  • Tap the system Paste affordance — no onPaste event fires; no JS callback; in DEV the warning prints once at mount

Confirmed on RN 0.83.6 + Expo 55.0.16 + new arch enabled.

Suggested fix

Use findNodeHandle from react-native, which is the public API and works across both legacy and Fabric (returns the underlying _nativeTag on Fabric):

import { findNodeHandle } from 'react-native';

const nativeTag = textInputRef.current
    ? findNodeHandle(textInputRef.current)
    : null;

findNodeHandle is a thin wrapper around the same renderer-internal tag lookup, just with the correct property name per renderer.

Happy to send a PR.

Workaround

For anyone hitting this before a fix lands, a patch-package / pnpm patch diff against lib/commonjs/PasteInput.js and lib/module/PasteInput.js swapping textInputRef.current?.__nativeTag for findNodeHandle(textInputRef.current) (with the import added in lib/module/PasteInput.js) restores paste interception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions