A Picker is a dropdown menu that lets users select one option from a list. It looks like a spinning wheel or dropdown on mobile devices.
Click to reveal answer
beginner
How do you import the DateTimePicker in React Native?
You import it from '@react-native-community/datetimepicker' package using: <br><code>import DateTimePicker from '@react-native-community/datetimepicker';</code>
Click to reveal answer
beginner
What prop controls the mode of the DateTimePicker?
The mode prop controls whether the picker shows a date, time, or both. Values can be 'date', 'time', or 'datetime'.
Click to reveal answer
beginner
How do you handle the selected value from a Picker?
You use the onValueChange prop to get the selected value and update your component's state to reflect the choice.
Click to reveal answer
intermediate
Why should you use accessibility labels with Picker and DateTimePicker?
Accessibility labels help screen readers describe the picker to users with disabilities, making your app usable by everyone.
Click to reveal answer
Which prop sets the selected value in a React Native Picker?
AcurrentValue
Bvalue
CdefaultValue
DselectedValue
✗ Incorrect
The selectedValue prop sets the current selected option in a Picker.
What package do you install to use DateTimePicker in React Native?
A@react-native-community/datetimepicker
Breact-native-picker
Creact-native-datepicker
Dreact-native-date-picker
✗ Incorrect
The official DateTimePicker is from '@react-native-community/datetimepicker'.
Which mode shows only the time in DateTimePicker?
Adatetime
Bdate
Ctime
Dtimer
✗ Incorrect
The mode 'time' shows only the time selection.
How do you open the DateTimePicker on Android?
AIt opens automatically on render
BUsing a button with onPress to set visibility
CBy calling a show() method
DBy setting a visible state and rendering conditionally
✗ Incorrect
On Android, you usually control visibility with a button press that sets a state to show the picker.
Which accessibility prop helps screen readers identify a Picker?
AaccessibilityLabel
BaccessibilityHint
Caria-label
DaccessibilityRole
✗ Incorrect
The accessibilityLabel describes the Picker for screen readers.
Explain how to implement a Picker in React Native and handle user selection.
Think about how you show options and save the chosen one.
You got /4 concepts.
Describe how to use DateTimePicker to select a date and time in a React Native app.
Consider how you open the picker and get the chosen date or time.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of a Picker component in React Native?
easy
A. To input text data
B. To display images in a gallery
C. To play audio files
D. To let users select one option from a list
Solution
Step 1: Understand Picker usage
A Picker is designed to show a list of options for the user to choose from.
Step 2: Compare with other components
Other options like text input or image gallery serve different purposes, not selection from a list.
Final Answer:
To let users select one option from a list -> Option D
Quick Check:
Picker = select one option [OK]
Hint: Picker is for choosing one item from many [OK]
Common Mistakes:
Confusing Picker with text input
Thinking Picker plays media
Assuming Picker shows images
2. Which of the following is the correct way to import the Picker component from @react-native-picker/picker?
easy
A. import { Picker } from 'react-native';
B. import Picker from '@react-native-picker/picker';
C. import { Picker } from '@react-native-picker/picker';
D. import Picker from 'react-native-picker';
Solution
Step 1: Check official import syntax
The Picker is exported as a named export from '@react-native-picker/picker', so curly braces are needed.
Step 2: Eliminate incorrect imports
Default import from the correct package or imports from wrong packages are incorrect.
Final Answer:
import { Picker } from '@react-native-picker/picker'; -> Option C
Quick Check:
Named import with braces [OK]
Hint: Use curly braces for named imports like Picker [OK]
Common Mistakes:
Using default import instead of named import
Importing from wrong package
Missing curly braces around Picker
3. Given this code snippet, what will be displayed when the user selects "Banana" from the Picker?
A. The 'value' prop should be 'date' instead of 'value'
B. The DatePicker component requires 'mode' prop
C. The 'onChange' callback parameters are incorrect
D. The 'setDate' function should not be called inside 'onChange'
Solution
Step 1: Review DatePicker required props
React Native DatePicker requires a 'mode' prop like 'date' or 'time' to work properly.
Step 2: Check other props correctness
'value' and 'onChange' usage is correct; 'setDate' is correctly called to update state.
Final Answer:
The DatePicker component requires 'mode' prop -> Option B
Quick Check:
Missing required 'mode' prop [OK]
Hint: DatePicker needs 'mode' prop to work [OK]
Common Mistakes:
Omitting 'mode' prop causes no date shown
Confusing 'value' with 'selected' prop
Ignoring event parameter in onChange
5. You want to create a form with a Picker for selecting a country and a DatePicker for selecting a birthdate. How do you ensure the UI updates correctly when the user changes either input?
hard
A. Use separate state variables for country and birthdate, update each on change
B. Use a single state object and never update it
C. Only update state when the form is submitted
D. Use refs instead of state to track selections
Solution
Step 1: Manage state for each input separately
Use one state variable for country and another for birthdate to track changes independently.
Step 2: Update state on user interaction
Update the corresponding state in onValueChange for Picker and onChange for DatePicker to reflect UI changes.
Final Answer:
Use separate state variables for country and birthdate, update each on change -> Option A
Quick Check:
Separate states updated on change [OK]
Hint: Track each input with its own state variable [OK]
Common Mistakes:
Using one state object but not updating it
Delaying state update until submit
Using refs instead of state for UI updates
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.