import React from 'react';
import { View, Text, Pressable } from 'react-native';
import { Switch, type SwitchRef } from 'react-native-cross-elements';
export default function Example() {
const [on, setOn] = React.useState(false);
const switchRef = React.useRef<SwitchRef>(null);
return (
<View style={{ gap: 12 }}>
<Switch ref={switchRef} defaultValue={on} onValueChange={setOn} />
<Pressable onPress={() => switchRef.current?.switch()}>
<Text style={{ color: '#6366f1' }}>Toggle programmatically</Text>
</Pressable>
</View>
);
}