Skip to content

@datadog/mobile-react-native-babel-plugin overwrites event handler props with noops #1069

@vhfmag

Description

@vhfmag

Describe the bug

When @datadog/mobile-react-native-babel-plugin finds a JSX element called TextInput that doesn't come from react-native, it injects onFocus at the end of the list of JSX attributes, overwriting any existing onFocus attributes.

Reproduction steps

  1. Clone https://github.com/vhfmag/datadog-babel-plugin-bug-repro
  2. Run pnpm i && pnpm run build
  3. Compare dist/WithBug.js and dist/WithoutBug.js

Or just check the screenshots below:

Image Image

SDK logs

No response

Expected behavior

ensureMandatoryAttributes should receive state and check if componentName is included in state.trackedComponents. The root cause of the issue seems to be that getJSXElementActionPaths doesn't include onFocus on actionPathNames because TextInput isn't tracked (presumably because it's not imported from react-native), which ensureMandatoryAttributes interprets as if the component was actually tracked but onFocus was missing, leading it to add one.

Affected SDK versions

I tested with @datadog/mobile-react-native-babel-plugin on both 2.13.1 and 2.13.2

Latest working SDK version

N/A

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

NPM

React Native Version

No response

Package.json Contents

{
  "name": "datadog-babel-plugin-bug-repro",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "babel src --out-dir dist"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "packageManager": "pnpm@10.18.0",
  "devDependencies": {
    "@babel/cli": "^7.28.3",
    "@babel/core": "^7.28.5",
    "@babel/preset-react": "^7.28.5",
    "@datadog/mobile-react-native-babel-plugin": "^2.13.2"
  },
  "dependencies": {
    "react": "^19.2.1"
  }
}

iOS Setup

No response

Android Setup

No response

Device Information

No response

Other relevant information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions