Complete the code to import the Picker component from @react-native-picker/picker.
import { [1] } from '@react-native-picker/picker';
The Picker component is imported from '@react-native-picker/picker' as Picker.
Complete the code to set the selected value state for the Picker component.
const [selectedValue, setSelectedValue] = useState([1]);The initial selected value is set to the string "java" to match one of the Picker items.
Fix the error in the Picker onValueChange handler to update the selected value.
<Picker
selectedValue={selectedValue}
onValueChange={(itemValue, itemIndex) => [1]
>The onValueChange handler should call setSelectedValue with the new itemValue to update the state.
Fill both blanks to create a DateTimePicker that shows when showPicker is true and updates the date state.
const [date, setDate] = useState(new Date());
const [showPicker, setShowPicker] = useState(false);
<DateTimePicker
value={date}
mode=[1]
display="default"
onChange={(event, selectedDate) => {
setShowPicker(false);
if (selectedDate) {
[2];
}
}}
/>The mode should be set to "date" to pick a date, and the onChange handler should update the date state by calling setDate(selectedDate).
Fill all three blanks to show the Picker with three items and update the selected value on change.
const [selected, setSelected] = useState("apple"); <Picker [3]=[1] onValueChange={value => [2] > <Picker.Item label="Apple" value="apple" /> <Picker.Item label="Banana" value="banana" /> <Picker.Item label="Cherry" value="cherry" /> </Picker>
The Picker's selectedValue prop should be the state variable selected. The onValueChange handler should call setSelected(value) to update the state. The last blank is the prop name selectedValue used in the Picker component.