Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Taps on a `Pressable` with more than one child are not tracked

Đang mở
#1,499 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@cdn34dd đang làm issue này rồi.

Từ ngày 21/10/2026.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, react-native, typescript
Lĩnh vực
analytics, mobile

Hướng nghiên cứu

Start by reading the startTracking and stopTracking code mentioned in the report, then inspect the JSX runtime interception and related unit tests for interceptOnPress. Reproduce with a release or dev=false bundle using a Pressable with multiple children, and compare its behavior with the one-child case. Done when taps on both named and unnamed multi-child Pressable components produce RUM actions and the tests cover the behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Describe the bug

Taps on a React Native Pressable with more than one child are not reported to RUM. The handler of the app runs, but the SDK adds no action. This happens with and without dd-action-name, in a bundle with __DEV__ === false.

We found it while naming our taps. Many taps were reported as RCTView, so we added dd-action-name to our buttons. It worked for most of them. On some buttons the name never showed up, and the tap was not in RUM at all, even though the button worked in the app.

In our tests with the buttons below:

  • A Pressable with one child: tap reported.
  • A Pressable with more than one child: no tap reported.
  • A Pressable with more than one child inside a parent that receives onPress and passes it down: tap reported.

A TouchableOpacity with more than one child was fine in our tests.

We suspect it has to do with jsxs. Babel uses it for elements with more than one child, and startTracking replaces only jsx. We did not verify this on a device. Only on an emulator.

Reproduction steps
  1. Use a bundle with __DEV__ === false (a release build, or Metro with dev=false). Set verbosity to DEBUG.
  2. Render this and tap each button once, in order:
import { Pressable, Text } from 'react-native'

const Owner = ({ onPress, name }: { onPress: () => void; name?: string }) => (
  <Pressable onPress={onPress} dd-action-name={name}>
    <Text>Two children</Text>
    <Text>Second child</Text>
  </Pressable>
)

export const Repro = () => (
  <>
    <Pressable onPress={() => console.log('DUMMY handler ran: A named, one child')} dd-action-name="Dummy A named, one child">
      <Text>A</Text>
    </Pressable>
    <Pressable onPress={() => console.log('DUMMY handler ran: B named, two children')} dd-action-name="Dummy B named, two children">
      <Text>B</Text>
      <Text>Second child</Text>
    </Pressable>
    <Owner onPress={() => console.log('DUMMY handler ran: C named, owner passes onPress')} name="Dummy C named, owner passes onPress" />
    <Pressable onPress={() => console.log('DUMMY handler ran: D unnamed, one child')}>
      <Text>D</Text>
    </Pressable>
    <Pressable onPress={() => console.log('DUMMY handler ran: E unnamed, two children')}>
      <Text>E</Text>
      <Text>Second child</Text>
    </Pressable>
    <Owner onPress={() => console.log('DUMMY handler ran: F unnamed, owner passes onPress')} />
  </>
)

Here is a recording of that test:

https://github.com/user-attachments/assets/6f903af7-56e1-4947-81b0-9e9ebc32c57a

SDK logs

Output of the component above in our app, one tap per button, in order. Both "two children" buttons (B and E) have no Adding RUM Action line.

DUMMY handler ran: A named, one child
DATADOG: Adding RUM Action "Dummy A named, one child" (TAP)
DUMMY handler ran: B named, two children
DUMMY handler ran: C named, owner passes onPress
DATADOG: Adding RUM Action "Dummy C named, owner passes onPress" (TAP)
DUMMY handler ran: D unnamed, one child
DATADOG: Adding RUM Action "RCTView" (TAP)
DUMMY handler ran: E unnamed, two children
DUMMY handler ran: F unnamed, owner passes onPress
DATADOG: Adding RUM Action "RCTView" (TAP)

"Owner passes onPress" means a parent component with one child receives onPress and passes the same function to the Pressable with two children.

Expected behavior

A RUM tap action for every Pressable with a handler, as for the one-child case.

We added jsxs next to jsx in a local patch. With the patch, the taps on the Pressable with more than one child are reported in the iOS simulator, and interceptOnPress runs in a unit test with a component that reads props.onPress. Not saying this is the right fix.

 const originalJsx = jsxRuntime?.jsx;
+const originalJsxs = jsxRuntime?.jsxs;
 ...
+if (originalJsxs) {
+  jsxRuntime.jsxs = (...args) => this.patchCreateElementFunction(originalJsxs, args);
+}

stopTracking restores jsxs like jsx.

Affected SDK versions

2.14.9 (tested). The source of 3.10.0 has the same code in startTracking; we did not run 3.10.0.

Latest working SDK version

Unknown. We did not test other versions.

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

No

Integration Methods

Yarn

React Native Version

0.81.5

Package.json Contents
  "@datadog/mobile-react-native": "^2.x",
  "@datadog/mobile-react-navigation": "^2.x",
  "expo": "^54.x",
  "react": "19.1.0",
  "react-native": "0.81.5"
iOS Setup

Podfile.lock has DatadogCore, DatadogInternal, DatadogLogs, DatadogRUM, DatadogTrace, DatadogWebViewTracking, DatadogCrashReporting 2.30.2 and DatadogSDKReactNative 2.14.9. Tested in the iOS simulator only.

Android Setup

com.datadoghq.dd-sdk-android-gradle-plugin 1.21.0, hermesEnabled=true, newArchEnabled=false. The native Datadog libraries (dd-sdk-android-rum, -logs, -trace, -webview) come from the React Native SDK at 2.26.2. We did not test on Android. The issues are in JavaScript, so we expect the same there.

Device Information

No response

Other relevant information

No response

Ngôn ngữ chính
TypeScript
Star
146
Fork
67
Merge trung bình
2 ngày 14 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DataDog/dd-sdk-reactnative

Tất cả issue của DataDog/dd-sdk-reactnative

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.