TrackedSwitch

Wraps Switch in a InputContext and automatically tracks InputChangeEvent for it.

TrackedSwitch: (props: SwitchProps & {
id: string,
trackValue?: boolean,
}) => Switch

Additional Props

typedefault value
requiredidstring
optionaltrackValuebooleanfalse

Automatic Events

Global Contexts

Usage examples

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

<TrackedSwitch
id="on-off"
onValueChange={toggleSwitch}
value={isEnabled}
/>

To track also the changed value and attach it to Event's GlobalContexts as InputValueContext:

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

<TrackedSwitch
id="on-off"
onValueChange={toggleSwitch}
value={isEnabled}
trackValue={true}
/>

Did you know ?

TrackedSwitch internally uses InputContextWrapper.