Image
Display a bundled asset or an image loaded by native code.
<Image image={landscape} resizeMode="cover" layout={{ width: 240, height: 200, }}/>
Bundle an image
Put a PNG, JPEG, or SVG in src/assets/. Import the file and pass it to the image prop. The bundler turns the import into an image loader and includes the resource in the native build.
import { Image } from 'react-nitro-renderer'
import crocus from './assets/crocus.jpg'
export function NotePhoto() {
return <Image image={crocus} resizeMode="cover" layout={{ width: 240, height: 160 }} />
}Keep density variants together, for example pin.png, pin@2x.png, and pin@3x.png. Import pin.png once. The native build groups the variants and the platform selects the appropriate scale. Rebuild the app when the files change. On Android, the build converts SVGs into VectorDrawable resources. An SVG using unsupported features fails at that step.
Choose how the image fits
Give the view a frame with layout. Its resizeMode controls how an image with different dimensions fits inside it.
| Mode | Result |
|---|---|
cover (default) | Fills the frame, cropping the image at the edges when necessary. |
contain | Fits the entire image while preserving its proportions. Useful for icons. |
center | Centers the image at its natural size. |
stretch | Scales each dimension to fill the frame, which can change the aspect ratio. |
Load images in a recycled cell
The image prop accepts a native image or an ImageLoader. Passing a loader lets the native view request the image when it becomes visible and drop it when it goes offscreen. Passing an already loaded image keeps it in memory while the view references it. A bundled asset import gives you a loader you can pass directly to each cell.
When a cell is reused for a different photo, pass the photo's identity as recyclingKey. Changing the key clears the previous image while the next one loads. List
To reveal the image through a shape or text, use MaskedView.