TrackedPressable
Wraps Pressable in a PressableContext and automatically tracks PressEvent for it.
TrackedPressable: (props: PressableProps & {
id?: string,
}) => Pressable
Additional Props
type | default value | ||
---|---|---|---|
optional | id | string | inferred from children |
info
In development mode, TrackedPressable will log an error to the console when failing to infer an identifier from children
.
Automatic Events
- PressEvent when
onPress
triggers.
Usage examples
A regular Pressable
import { TrackedPressable } from '@objectiv/tracker-react-native';
<TrackedPressable
onPress={onPressFunction}
>
<Text>I'm pressable!</Text>
</TrackedPressable>
Non parseable children
import { TrackedPressable } from '@objectiv/tracker-react-native';
<TrackedPressable
onPress={onPressFunction}
id="thumb-down"
>
<Text>👎</Text>
</TrackedPressable>
Custom identifier
import { TrackedPressable } from '@objectiv/tracker-react-native';
<TrackedPressable
onPress={onPressFunction}
id="custom-analytics-id"
>
<Text>Press me!</Text>
</TrackedPressable>
Did you know ?
TrackedPressable
internally uses PressableContextWrapper.