LinkContextWrapper
Wraps its children in a LinkContext.
Children can be a ReactNode or a Render Props function receiving TrackingContext.
LinkContextWrapper: (props: {
children: ReactNode | ((parameters: TrackingContext) => ReactNode),
id: string,
href: string,
}) => ReactElement
Parameters
type | ||
---|---|---|
required | children | ReactNode | ((parameters: TrackingContext) => ReactNode) |
required | id | string |
required | href | string |
Returns
ReactElement
Usage example
Enrich Locations
import { LinkContextWrapper } from '@objectiv/tracker-react-native';
const to = 'Privacy';
<LinkContextWrapper id={'privacy'} href={to}>
<Link to={to}>Privacy</Link>
</LinkContextWrapper>
Tracking via Render Props
import {
LinkContextWrapper,
trackPressEvent
} from '@objectiv/tracker-react-native';
const to = 'Privacy';
<LinkContextWrapper id={'privacy'} href={to}>
{(trackingContext) => (
<Link
to={to}
onPress={() => trackPressEvent(trackingContext)}
>
Privacy
</Link>
)}
</LinkContextWrapper>
info
The above is just an example to illustrate the Render Props functionality.
Check out our Tracked Components for ready-to-use Components.
Did you know ?
LinkContextWrapper
internally uses LocationContextWrapper.