ContentContextWrapper

Wraps its children in a ContentContext.
Children can be a ReactNode or a Render Props function receiving TrackingContext.

ContentContextWrapper: (props: { 
children: ReactNode | ((parameters: TrackingContext) => ReactNode),
id: string
}) => ReactElement

Parameters

type
requiredchildrenReactNode | ((parameters: TrackingContext) => void)
requiredidstring

Returns

ReactElement

Usage examples

Enrich Locations

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

<ContentContextWrapper id={'content'}>
<View>
...
<ContentContextWrapper id={'sub-content'}>
<Button title={'Go!'} onPress={doSomething}/>
</ContentContextWrapper>
</View>
<View>
...
</View>
</ContentContextWrapper>

Tracking via Render Props

import { 
ContentContextWrapper,
trackPressEvent
} from '@objectiv/tracker-react-native';

<ContentContextWrapper id={'content'}>
<View>
<ContentContextWrapper id={'sub-content'}>
{(trackingContext) => (
<Button
title={'Hi!'}
onPress={() => {
trackPressEvent(trackingContext);
doSomethingElse();
}}/>
)}
</ContentContextWrapper>
</View>
<View>
...
</View>
</ContentContextWrapper>

Did you know ?

ContentContextWrapper internally uses LocationContextWrapper.