Complete the code to import the Switch component from React Native.
import { [1] } from 'react-native';
The Switch component is imported from react-native to create toggle switches.
Complete the code to set the initial state for a checkbox using React useState hook.
const [isChecked, [1]] = React.useState(false);The setter function for isChecked state is conventionally named setIsChecked.
Fix the error in the Switch component to update the state when toggled.
<Switch value={isEnabled} onValueChange=[1] />The onValueChange handler receives the new value and should update the state accordingly using (value) => setIsEnabled(value).
Fill both blanks to create a checkbox using a Pressable and a conditional checkmark.
const [checked, setChecked] = React.useState(false);
<Pressable onPress={() => setChecked([1])}>
{checked && <Text>[2]</Text>}
</Pressable>Pressing toggles the checked state by setting it to the opposite (!checked). The checkmark symbol '✓' is shown when checked is true.
Fill all three blanks to create a controlled Switch with label and accessibility.
const [isOn, setIsOn] = React.useState(false); <View accessible accessibilityLabel=[1]> <Text>[2]</Text> <Switch value={isOn} onValueChange=[3] /> </View>
The accessibilityLabel describes the switch for screen readers, so use a descriptive string like "Toggle setting". The label text should describe the switch, e.g. "Enable feature". The onValueChange handler updates the state with the new value.