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