Babel plugin: an undefined `onLongPress` becomes a function, so `Pressable` drops `onPress` after a long press
Los mantenedores suelen responder en 1 día
@cdn34dd ya está trabajando en esto.
Desde el 22/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, react-native, typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 146
- Forks
- 67
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 19
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de DataDog/dd-sdk-reactnative
-
Taps on a `Pressable` with more than one child are not trackedPosiblemente ocupada @cdn34dd la tomó hace 2 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
DataDog/dd-sdk-reactnative#1499 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[actionNameAttribute] prop doesn't accept value with curly bracesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
DataDog/dd-sdk-reactnative#1486 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Expose Android app startup Activity filtering in the React Native SDKPosiblemente ocupada @sbarrio la tomó hace 14 días. Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
DataDog/dd-sdk-reactnative#1485 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
GraphQL variables with non-ASCII contents will make Apollo Client request throw errorPosiblemente ocupada @cdn34dd la tomó hace 16 días. Abiertoawaiting response bug
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
DataDog/dd-sdk-reactnative#1482 · 2 comentarios · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
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 callPosiblemente ocupada @cdn34dd la tomó hace 14 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
DataDog/dd-sdk-reactnative#1377 · 1 comentario · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de DataDog/dd-sdk-reactnative
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
db-ux-design-system/core-web#8613 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
foxglove/mcap#1907 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug internal-plugin pr-welcome upstream
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dsh-tauri-desk/deepseek-harness-desktop#1225 · 1 comentario ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
unjs/unhead#1027 · 1 reacción ·
Los mantenedores suelen responder en 1 día