Image
A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll.
Example usage:
renderImages: function() {
return (
<View>
<Image
style={styles.icon}
source={require('image!myIcon')}
/>
<Image
style={styles.logo}
source={{uri: 'https://reactjs.org/logo-og.png'}}
/>
</View>
);
},
Props
capInsets
onLayout
source
style
testID
accessibilityLabel
accessible
resizeMode
defaultSource
onError
onLoad
onLoadEnd
onLoadStart
onProgress
Reference
Props
capInsets
When the image is resized, the corners of the size specified by capInsets will stay a fixed size, but the center content and borders of the image will be stretched. This is useful for creating resizable rounded buttons, shadows, and other resizable assets. More info on Apple documentation
Type | Required | Platform |
---|---|---|
object: {top: number, left: number, bottom: number, right: number} | No | iOS |
onLayout
Invoked on mount and layout changes with {nativeEvent: {layout: {x, y, width, height}}}
.
Type | Required |
---|---|
function | No |
source
uri
is a string representing the resource identifier for the image, which could be an http address, a local file path, or the name of a static image resource (which should be wrapped in the require('image!name')
function).
Type | Required |
---|---|
object: {uri: string} | No |
style
Type | Required |
---|---|
style | No |
backgroundColor
: stringborderColor
: stringborderRadius
: numberborderWidth
: numberopacity
: numberoverflow
: enum('visible', 'hidden')resizeMode
: Object.keys(ImageResizeMode)tintColor
: string
testID
A unique identifier for this element to be used in UI Automation testing scripts.
Type | Required |
---|---|
string | No |
accessibilityLabel
The text that's read by the screen reader when the user interacts with the image.
Type | Required | Platform |
---|---|---|
string | No | iOS |
accessible
When true, indicates the image is an accessibility element.
Type | Required | Platform |
---|---|---|
bool | No | iOS |
resizeMode
Determines how to resize the image when the frame doesn't match the raw image dimensions.
Type | Required |
---|---|
enum('cover', 'contain', 'stretch') | No |
defaultSource
A static image to display while downloading the final image off the network.
Type | Required | Platform |
---|---|---|
object: {uri: string} | No | iOS |
onError
Invoked on load error with {nativeEvent: {error}}
Type | Required | Platform |
---|---|---|
function | No | iOS |
onLoad
Invoked when load completes successfully
Type | Required | Platform |
---|---|---|
function | No | iOS |
onLoadEnd
Invoked when load either succeeds or fails
Type | Required | Platform |
---|---|---|
function | No | iOS |
onLoadStart
Invoked on load start
Type | Required | Platform |
---|---|---|
function | No | iOS |
onProgress
Invoked on download progress with {nativeEvent: {loaded, total}}
Type | Required | Platform |
---|---|---|
function | No | iOS |