React Native theorytheory 0/50 · 0%
Components · easy

12. Images and assets

Local vs remote images and resolution variants.

Local images are required with `require` and bundled at build time; remote images use `source={{ uri }}` and are fetched at runtime, which is how you'd show a token or NFT icon from IPFS or a CDN.

import { Image } from "react-native";

function Icon() {
  return <Image source={require("./assets/icon.png")} style={{ width: 32, height: 32 }} />;
}

function TokenLogo({ uri }: { uri: string }) {
  return <Image source={{ uri }} style={{ width: 32, height: 32 }} />;
}

Providing `@2x`/`@3x` suffixed variants of a local asset lets React Native pick the right density automatically on higher-resolution screens.

Check your understanding

  1. 1. How do you reference a bundled local image?

  2. 2. How do you show a remote image by URL?

  3. 3. What do @2x/@3x suffixes provide?