Challenge - 5 Problems
Image Optimization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
Image loading performance in React Native
Which option correctly optimizes image loading to improve app performance in React Native?
React Native
import { Image } from 'react-native'; export default function App() { return ( <Image source={{ uri: 'https://example.com/photo.jpg' }} style={{ width: 100, height: 100 }} /> ); }
Attempts:
2 left
💡 Hint
Consider props that control image scaling for better rendering performance.
✗ Incorrect
Using progressiveRenderingEnabled={true} enables progressive image loading, which can improve perceived performance by showing a low-res version first.
🧠 Conceptual
intermediate1:30remaining
Best image format for mobile apps
Which image format is generally best for mobile apps to balance quality and file size?
Attempts:
2 left
💡 Hint
Consider formats that compress well and are widely supported.
✗ Incorrect
JPEG compresses images efficiently with good quality, making it ideal for photos in mobile apps.
❓ lifecycle
advanced2:30remaining
Handling image loading errors
What is the correct way to handle an image loading error in React Native to show a fallback image?
React Native
import React, { useState } from 'react'; import { Image } from 'react-native'; export default function App() { const [error, setError] = useState(false); return ( <Image source={error ? require('./fallback.png') : { uri: 'https://example.com/photo.jpg' }} style={{ width: 100, height: 100 }} onError={() => setError(true)} /> ); }
Attempts:
2 left
💡 Hint
React Native Image component has a prop for error handling.
✗ Incorrect
The onError prop triggers when image loading fails, allowing you to update state and show a fallback image.
🔧 Debug
advanced2:00remaining
Why does this image not display?
Given this React Native code, why does the image not show on the screen?
React Native
import { Image } from 'react-native'; export default function App() { return ( <Image source={{ uri: 'https://example.com/photo.jpg' }} /> ); }
Attempts:
2 left
💡 Hint
Think about what React Native needs to know to show an image size.
✗ Incorrect
Without width and height styles, React Native cannot allocate space for the image, so it does not appear.
expert
3:00remaining
Optimizing image-heavy screen navigation
You have a screen with many large images. Which approach best improves navigation speed and memory use in React Native?
Attempts:
2 left
💡 Hint
Think about how to load only visible images to save memory.
✗ Incorrect
FlatList with windowSize and removeClippedSubviews loads only visible items, improving performance and memory.