Challenge - 5 Problems
Image Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this React Native Image component display?
Consider this code snippet in a React Native app:
What will the user see when this runs?
import React from 'react';
import { Image } from 'react-native';
export default function App() {
return (
);
}What will the user see when this runs?
React Native
import React from 'react'; import { Image } from 'react-native'; export default function App() { return ( <Image source={{ uri: 'https://example.com/image.png' }} style={{ width: 100, height: 100 }} accessibilityLabel="Example remote image" /> ); }
Attempts:
2 left
💡 Hint
Think about how React Native loads images from URLs using the uri property.
✗ Incorrect
The Image component with source={{ uri: '...' }} loads an image from the internet. The style sets its size. Accessibility label helps screen readers.
📝 Syntax
intermediate2:00remaining
Which option correctly loads a local image in React Native?
You want to display a local image named 'logo.png' stored in your project's 'assets' folder. Which code snippet correctly loads this image?
Attempts:
2 left
💡 Hint
Local images require the require() function in React Native.
✗ Incorrect
Local images must be imported using require(). The source prop expects an object returned by require(). Using uri for local files or src prop is incorrect.
❓ lifecycle
advanced2:00remaining
What happens if the remote image URL is invalid or unreachable?
In React Native, if you use an Image component with a remote URL that does not exist or the device is offline, what will happen?
Attempts:
2 left
💡 Hint
Think about what React Native does when it cannot load an image from the internet.
✗ Incorrect
If the remote image cannot load, React Native shows an empty space. It does not crash or show a default image automatically. Caching behavior depends on platform and is not guaranteed.
🧠 Conceptual
advanced2:00remaining
Why is it important to set width and height on Image components in React Native?
In React Native, what is the main reason you must specify width and height styles on Image components?
Attempts:
2 left
💡 Hint
Think about how layout works in mobile apps and how images affect it.
✗ Incorrect
React Native requires width and height to allocate space for images during layout. Without them, the image may not appear or cause layout issues. Width and height do not affect file size or accessibility directly.
🔧 Debug
expert2:00remaining
Why does this local image fail to display in React Native?
You wrote this code to display a local image:
But the image does not show. What is the cause?
import React from 'react';
import { Image } from 'react-native';
export default function App() {
return (
);
}But the image does not show. What is the cause?
React Native
import React from 'react'; import { Image } from 'react-native'; export default function App() { return ( <Image source={{ uri: './assets/icon.png' }} style={{ width: 40, height: 40 }} /> ); }
Attempts:
2 left
💡 Hint
Check how local images are loaded differently from remote images in React Native.
✗ Incorrect
Local images must be loaded with require(), not with uri and relative paths. Using uri with a relative path causes the image not to load.