LocationContextWrapper
Wraps its children in the given LocationContext instance.
Children can be a ReactNode or a Render Props function receiving TrackingContext.
LocationContextWrapper: (props: {
children: ReactNode | ((parameters: TrackingContext) => ReactNode),
locationContext: LocationContext
}) => ReactElement
caution
LocationContextWrapper
is a lower-level Component. Unless really needed, it's easier to use specific Location Wrappers.
Parameters
type | ||
---|---|---|
required | children | ReactNode | ((parameters: TrackingContext) => void) |
required | locationContext | LocationContext |
Returns
ReactElement
Usage example
Enrich Locations
import {
LocationContextWrapper,
makeContentContext
} from '@objectiv/tracker-react-native';
<LocationContextWrapper
locationContext={ makeContentContext({ id: 'content' }) }
>
<View>
...
</View>
<View>
...
</View>
</LocationContextWrapper>
Tracking via Render Props
import {
LocationContextWrapper,
trackPressEvent
} from '@objectiv/tracker-react-native';
<LocationContextWrapper
locationContext={ makeContentContext({ id: 'content' }) }
>
{(trackingContext) => (
<>
<TouchableWithoutFeedback onPress={() => trackPressEvent(trackingContext)}>
Hi!
</TouchableWithoutFeedback>
<View>
...
</View>
</>
)}
</LocationContextWrapper>