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
requiredchildrenReactNode | ((parameters: TrackingContext) => void)
requiredlocationContextLocationContext

Returns

ReactElement

Usage example

Enrich Locations

import { 
LocationContextWrapper,
makeContentContext
} from '@objectiv/tracker-react';

<LocationContextWrapper
locationContext={ makeContentContext({ id: 'content' }) }
>
<div>
...
</div>
<span>
...
</span>
</LocationContextWrapper>

Tracking via Render Props

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

<LocationContextWrapper
locationContext={ makeContentContext({ id: 'content' }) }
>
{(trackingContext) => (
<>
<div onClick={() => trackPressEvent(trackingContext)}>
Hi!
</div>
<span>
...
</span>
</>
)}
</LocationContextWrapper>