TrackedText

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

TrackedText: (props: TextProps & {
id?: string,
}) => Text

Additional Props

typedefault value
optionalidstringinferred from children
info

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

Automatic Events

Usage examples

A regular Text

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

<TrackedText
onPress={onPressFunction}
>
I'm a pressable text!
</TrackedText>

Non parseable children

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

<TrackedText
onPress={onPressFunction}
id="thumb-down"
>
👎
</TrackedText>

Custom identifier

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

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

Did you know ?

TrackedText internally uses PressableContextWrapper.