Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build performant React Native and Expo apps with best practices for lists, animations, and navigation
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/ui-expo-image.md
1---2title: Use expo-image for Optimized Images3impact: HIGH4impactDescription: memory efficiency, caching, blurhash placeholders, progressive loading5tags: images, performance, expo-image, ui6---78## Use expo-image for Optimized Images910Use `expo-image` instead of React Native's `Image`. It provides memory-efficient caching, blurhash placeholders, progressive loading, and better performance for lists.1112**Incorrect (React Native Image):**1314```tsx15import { Image } from 'react-native'1617function Avatar({ url }: { url: string }) {18return <Image source={{ uri: url }} style={styles.avatar} />19}20```2122**Correct (expo-image):**2324```tsx25import { Image } from 'expo-image'2627function Avatar({ url }: { url: string }) {28return <Image source={{ uri: url }} style={styles.avatar} />29}30```3132**With blurhash placeholder:**3334```tsx35<Image36source={{ uri: url }}37placeholder={{ blurhash: 'LGF5]+Yk^6#M@-5c,1J5@[or[Q6.' }}38contentFit="cover"39transition={200}40style={styles.image}41/>42```4344**With priority and caching:**4546```tsx47<Image48source={{ uri: url }}49priority="high"50cachePolicy="memory-disk"51style={styles.hero}52/>53```5455**Key props:**5657- `placeholder` — Blurhash or thumbnail while loading58- `contentFit` — `cover`, `contain`, `fill`, `scale-down`59- `transition` — Fade-in duration (ms)60- `priority` — `low`, `normal`, `high`61- `cachePolicy` — `memory`, `disk`, `memory-disk`, `none`62- `recyclingKey` — Unique key for list recycling6364For cross-platform (web + native), use `SolitoImage` from `solito/image` which uses `expo-image` under the hood.6566Reference: [expo-image](https://docs.expo.dev/versions/latest/sdk/image/)67