Bird
Raised Fist0
React Nativemobile~10 mins

Image component (local and remote) in React Native - UI Render Trace

Choose your learning style10 modes available
Component - Image component (local and remote)

The Image component in React Native displays pictures in your app. It can show images stored inside the app (local) or images loaded from the internet (remote). This helps make your app visually interesting and informative.

Widget Tree
View
├── Text
├── Image (local)
└── Image (remote)
The main container is a View holding three children stacked vertically: a Text label, an Image showing a local picture, and an Image showing a remote picture from a URL.
Render Trace - 4 Steps
Step 1: View
Step 2: Text
Step 3: Image (local)
Step 4: Image (remote)
State Change - Re-render
Trigger:No state change in this static image display example
Before
Initial render with local and remote images displayed
→
After
No change
Re-renders:No re-render triggered
UI Quiz - 3 Questions
Test your understanding
What does the local Image component use to load its picture?
AA base64 encoded string
Brequire() with a local file path
CA web URL string
DAn inline SVG code
Key Insight
Using the Image component with local and remote sources lets you show pictures from inside your app or from the internet. Always set width and height to avoid layout jumps. Wrapping images in a View with flexDirection column and alignItems center arranges them nicely stacked and centered on the screen.

Practice

(1/5)
1. Which of the following is the correct way to display a local image in React Native using the Image component?
easy
A.
B.
C.
D.

Solution

  1. Step 1: Understand local image usage

    Local images require the require() function to load the file correctly in React Native.
  2. Step 2: Check the syntax for local images

    The correct syntax uses source={require('path')}, not uri or src attributes.
  3. Final Answer:

    <Image source={require('./assets/photo.png')} /> -> Option C
  4. Quick Check:

    Local images use require() = C [OK]
Hint: Local images always use require() inside source prop [OK]
Common Mistakes:
  • Using uri for local images
  • Using src attribute instead of source
  • Passing string directly without require()
2. Which of the following is the correct syntax to display a remote image from a URL in React Native?
easy
A.
B.
C.
D.

Solution

  1. Step 1: Identify remote image syntax

    Remote images require an object with a uri key inside the source prop.
  2. Step 2: Verify correct object structure

    The correct syntax is source={{ uri: 'URL' }}, not using require or src attributes.
  3. Final Answer:

    <Image source={{ uri: 'https://example.com/image.png' }} /> -> Option D
  4. Quick Check:

    Remote images use source={{ uri: URL }} = D [OK]
Hint: Remote images need source={{ uri: 'URL' }} syntax [OK]
Common Mistakes:
  • Using require() for remote URLs
  • Using src attribute instead of source
  • Passing URL as a string directly to source
3. What will be the result of this React Native code snippet?
import React from 'react';
import { Image } from 'react-native';

export default function App() {
  return (
    <Image source={{ uri: 'https://example.com/pic.jpg' }} style={{ width: 100, height: 100 }} accessibilityLabel="Example image" />
  );
}
medium
A. A 100x100 image loaded from the internet with accessibility label
B. A blank space because remote images are not supported
C. An error because accessibilityLabel is not valid on Image
D. A local image displayed with size 100x100

Solution

  1. Step 1: Analyze the image source

    The source uses a remote URL with uri, so it loads an internet image.
  2. Step 2: Check style and accessibility

    The style sets width and height to 100, and accessibilityLabel is valid for screen readers.
  3. Final Answer:

    A 100x100 image loaded from the internet with accessibility label -> Option A
  4. Quick Check:

    Remote image with size and label = B [OK]
Hint: Remote images need uri and style size to display properly [OK]
Common Mistakes:
  • Forgetting to set width and height style
  • Thinking accessibilityLabel causes error
  • Assuming remote images won't load
4. Identify the error in this React Native code snippet that tries to display a local image:
import React from 'react';
import { Image } from 'react-native';

export default function App() {
  return (
    <Image source="./assets/photo.png" style={{ width: 50, height: 50 }} />
  );
}
medium
A. The style prop must be outside the Image component
B. The source prop should use require() for local images
C. The Image component cannot display local images
D. The width and height must be strings, not numbers

Solution

  1. Step 1: Check source prop for local image

    Local images must use require() inside the source prop, not a string path.
  2. Step 2: Verify style and component usage

    The style prop is correctly placed and numbers for width/height are valid in React Native.
  3. Final Answer:

    The source prop should use require() for local images -> Option B
  4. Quick Check:

    Local images need require() = A [OK]
Hint: Local images must use require() inside source prop [OK]
Common Mistakes:
  • Passing string path directly to source
  • Misplacing style prop
  • Using strings for width/height instead of numbers
5. You want to display a local image and a remote image side by side in React Native. Which code snippet correctly implements this with accessibility labels and proper sizing?
hard
A.
B.
C.
D.

Solution

  1. Step 1: Verify local and remote image sources

    Local images must use require(), remote images use source={{ uri: URL }}.
  2. Step 2: Check layout and accessibility

    Using flexDirection: 'row' places images side by side, and accessibilityLabel is correctly added.
  3. Final Answer:

    Code snippet with require() for local, uri for remote, row layout, and labels -> Option A
  4. Quick Check:

    Local require + remote uri + row layout = A [OK]
Hint: Use require() for local, uri for remote, flexDirection row for side by side [OK]
Common Mistakes:
  • Using string path instead of require() for local images
  • Using uri with local file paths
  • Missing accessibility labels
  • Incorrect flexDirection for horizontal layout
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard