React Native Image
The Image component is used to display the image on the screen. The image can be loaded from different source such as static resources, temporary local files, local disc, network images, etc.
Static Image Resources
The static images are added in app by placing it in somewhere in the source code directory and provide its path as:
In the above syntax, the packager will look for icon_name.png in the same folder as the component that requires it. To load the image on a specific platform, it should be named by specifying the platform as extensions such as icon_name.ios.png and icon_name.android.png.
Images from Hybrid App's Resources
The hybrid app which is built (UI) by using both React Native and platform code can also uses the image which is bundled into the app.
The image included through Xcode asset catalogs or in Android drawable folder are consumes without their extension.
The images within the Android assets folder, use the scheme: asset:/ with image extension.
The dynamic and network images are also be displayed in the Image component. To access the network image, it is required to specify the dimensions of image manually.
It is recommended to use https in order to satisfy the App Transport Security requirements on iOS.
Uri Data Images
The encoded image data use the "data:" uri scheme in the image component. The data image also required to specify the dimension of the image.
Background Image via Nesting
The background image is set using the ImageBackground component. It is also the same props as Image. We can add any component as children on the top of it.
React Native Image Example