Display Image in React Native - Mobile Application - Example

 Congratulations! You are standing in the right place!

In this article, we will discuss how to exhibit image in react native application utilizing online URL.

We are going to create a mobile app like below,


Implementation:

You must set up your local development environment. Follow the below link to set up your local environment.


After executing the commands mentioned in this link, a folder with a specified name is created with the following contents.




Next, we are going to edit the App.js file and write the below code.

import React, { Component } from 'react';
import {
AppRegistry, Image
} from 'react-native';

export default class App extends Component {
render() {

let Image_URL ={ uri: 'https://raw.githubusercontent.com/knowledgefactory4u/
Javascript/master/photo-1611337449232-e3183e932494.jpeg'};

return (
<Image source={Image_URL} style = {{height: 700, resizeMode : 'stretch',
margin: 5 }} />
);
}
}

AppRegistry.registerComponent('App', () => App);

Explanation

Integrate Image component in import block.

import {
AppRegistry, Image
} from 'react-native';


Engender let variable and assign Image URL to let variable utilizing URI.

let Image_URL ={ uri: 'https://raw.githubusercontent.com/knowledgefactory4u/
Javascript/master/photo-1611337449232-e3183e932494.jpeg'};

Integrate Source attribute in Image tag and Assign Let variable name to it.

return (
<Image source={Image_URL} style = {{height: 700, resizeMode : 'stretch',
margin: 5 }} />
);
}
}

Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Java Stream API - How to convert List of objects to another List of objects using Java streams?

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Java, Spring Boot Mini Project - Library Management System - Download

ReactJS, Spring Boot JWT Authentication Example

Top 5 Java ORM tools - 2024

Java - Blowfish Encryption and decryption Example

Spring boot video streaming example-HTML5

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete