TrackedSwitch
Wraps Switch in a InputContext and automatically tracks InputChangeEvent for it.
TrackedSwitch: (props: SwitchProps & {
id: string,
trackValue?: boolean,
}) => Switch
Additional Props
type | default value | ||
---|---|---|---|
required | id | string | |
optional | trackValue | boolean | false |
Automatic Events
- InputChangeEvent when
onValueChange
triggers.
Global Contexts
- InputValueContext with the changed value, if
trackValue
is set totrue
.
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.
See also