Babel plugin: an undefined `onLongPress` becomes a function, so `Pressable` drops `onPress` after a long press
メンテナーはふだん 1 日以内に返信
@cdn34dd がすでに取り組んでいます。
2026年10月22日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, react-native, typescript
調査の方向性
The issue identifies generated Babel output and the handler transformation in the React Native Babel plugin, but gives no source file or test path. Start by locating the transformation that wraps handlers passed by reference and the tests covering its generated output. Done means an undefined handler remains undefined and the regression is covered; the reporter says they already have a fix ready and plan to open a PR.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When a tracked handler is passed by reference and its value is undefined at runtime (for example an optional prop), the babel plugin still replaces it with a wrapper function. The component therefore always receives a defined handler.
For Pressable this changes behavior. React Native's Pressability skips onPress on release when onLongPress != null and the press was held longer than delayLongPress (500ms by default). Because the plugin wraps onLongPress even when it is undefined, every press held for more than 500ms no longer calls onPress, even though the app never set a long-press handler.
This is related to #1226. The fix for it (#1243, released in 3.3.0) added optional chaining (onLongPress?.(...args)), which stops the crash, but the prop itself is still always a function.
Generated output (3.5.0, unchanged in 3.11.0 and on develop):
onLongPress: (...args) => {
if (DdBabelInteractionTracking.getInstance()) return DdBabelInteractionTracking.getInstance().wrapRumAction(onLongPress, "TAP", { /* ... */ })(...args);
else return onLongPress?.(...args);
}
Reproduction steps
import { Pressable, Text } from 'react-native';
const Button = ({ onPress, onLongPress }: { onPress: () => void; onLongPress?: () => void }) => (
<Pressable onPress={onPress} onLongPress={onLongPress}>
<Text>Press me</Text>
</Pressable>
);
// Usage: no onLongPress is passed
<Button onPress={() => console.log('pressed')} />
- Enable
@datadog/mobile-react-native-babel-plugininbabel.config.js. - Tap the button:
pressedis logged. - Press and hold the button for more than 500ms, then release: nothing is logged.
- Remove the babel plugin (or pass
{...(onLongPress ? { onLongPress } : {})}instead ofonLongPress={onLongPress}): the long press logspressedagain.
SDK logs
N/A (no error is thrown; onPress is silently not called).
Expected behavior
A handler that is undefined at runtime stays undefined, so the component behaves the same with and without the plugin. For example:
onLongPress: onLongPress != null ? (...args) => { /* RUM wrapper */ } : undefined
Affected SDK versions
@datadog/mobile-react-native-babel-plugin 3.5.0 (also present in 3.11.0 and develop), with @datadog/mobile-react-native 3.9.0
Latest working SDK version
N/A (since the babel plugin started wrapping handlers by reference)
Did you confirm if the latest SDK version fixes the bug?
Yes
Integration Methods
NPM
React Native Version
0.86.3 (New Architecture, Hermes)
Package.json Contents
No response
iOS Setup
No response
Android Setup
No response
Device Information
iOS Simulator, iPhone 17 Pro Max
Other relevant information
Any tracked component that changes behavior based on whether a handler is set is affected the same way (for Pressable, onLongPress is the visible case). I have a fix ready and will open a PR referencing this issue.
- 主要言語
- TypeScript
- スター
- 146
- フォーク
- 67
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DataDog/dd-sdk-reactnative のほかの issue
-
Taps on a `Pressable` with more than one child are not tracked対応中かも @cdn34dd が 2 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
DataDog/dd-sdk-reactnative#1499 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[actionNameAttribute] prop doesn't accept value with curly braces対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
DataDog/dd-sdk-reactnative#1486 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
Expose Android app startup Activity filtering in the React Native SDK対応中かも @sbarrio が 14 日前に担当しました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DataDog/dd-sdk-reactnative#1485 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
GraphQL variables with non-ASCII contents will make Apollo Client request throw error対応中かも @cdn34dd が 16 日前に担当しました。 オープンawaiting response bug
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
DataDog/dd-sdk-reactnative#1482 · コメント 2 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Interaction tracking records nothing: the babel plugin's injected import makes Metro bundle a second copy of the SDK, so DdBabelInteractionTracking.config is set on a different class than instrumented handlers call対応中かも @cdn34dd が 14 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
DataDog/dd-sdk-reactnative#1377 · コメント 1 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
DataDog/dd-sdk-reactnative の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
db-ux-design-system/core-web#8613 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug:new
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
callstackincubator/simlock#934 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
gchq/LD-Explorer#286 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
foxglove/mcap#1907 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信