Challenge - 5 Problems
Image Picker Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens when the user taps the image picker button?
In a React Native app using the
expo-image-picker library, what is the expected behavior when the user taps the button that triggers the image picker?Attempts:
2 left
💡 Hint
Think about what the image picker library is designed to do when triggered.
✗ Incorrect
The image picker library opens the device's photo gallery or camera to let the user select or take a photo. If the button triggers the picker correctly, the gallery appears.
📝 Syntax
intermediate2:00remaining
Which code snippet correctly requests permission to access the media library?
Select the correct React Native code snippet using
expo-image-picker to request permission to access the media library.Attempts:
2 left
💡 Hint
Look for the official method name to request media library permissions.
✗ Incorrect
The correct method is
requestMediaLibraryPermissionsAsync() which returns an object containing the status.❓ lifecycle
advanced2:00remaining
When should you request image picker permissions in a React Native app?
Choose the best lifecycle moment to request image picker permissions in a React Native functional component.
Attempts:
2 left
💡 Hint
Think about when you want to ask for permission to avoid delays during user interaction.
✗ Incorrect
Requesting permissions once when the component loads improves user experience by avoiding repeated prompts.
🔧 Debug
advanced2:00remaining
Why does this image picker code fail to show the selected image?
Given this code snippet, why does the selected image not appear on the screen?
const [image, setImage] = useState(null);
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
quality: 1,
});
if (!result.canceled) {
setImage(result.assets[0].uri);
}
};
return ({image && } );
Attempts:
2 left
💡 Hint
Check the structure of the result object returned by the image picker.
✗ Incorrect
In recent versions, the picker returns an object with an assets array. The image URI is at result.assets[0].uri, not result.uri.
🧠 Conceptual
expert2:00remaining
What is the main reason to ask for image picker permissions before user interaction?
Why is it better to request image picker permissions when the app or component loads rather than when the user taps the button to pick an image?
Attempts:
2 left
💡 Hint
Think about user experience and timing of permission dialogs.
✗ Incorrect
Requesting permissions early prevents unexpected popups during user actions, making the app feel smoother.