TrackedTouchableOpacity

Wraps TouchableOpacity in a PressableContext and automatically tracks PressEvent for it.

TrackedTouchableOpacity: (props: TouchableOpacityProps & {
id?: string,
}) => TouchableOpacity

Additional Props

typedefault value
optionalidstringinferred from children
info

In development mode, TrackedTouchableOpacity will log an error to the console when failing to infer an identifier from children.

Automatic Events

Usage examples

A regular TouchableOpacity

import { TrackedTouchableOpacity } from '@objectiv/tracker-react-native';

<TrackedTouchableOpacity
onPress={onPressFunction}
>
<View>
<Text>Press me!</Text>
</View>
</TrackedTouchableOpacity>

Non parseable children

import { TrackedTouchableOpacity } from '@objectiv/tracker-react-native';

<TrackedTouchableOpacity
onPress={onPressFunction}
id="thumb-down"
>
<View>
<Text>👎</Text>
</View>
</TrackedTouchableOpacity>

Custom identifier

import { TrackedTouchableOpacity } from '@objectiv/tracker-react-native';

<TrackedTouchableOpacity
onPress={onPressFunction}
id="custom-analytics-id"
>
<View>
<Text>Press me!</Text>
</View>
</TrackedTouchableOpacity>

Did you know ?

TrackedTouchableOpacity internally uses PressableContextWrapper.