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 }} />
);
}
}

Comments

Popular posts from this blog

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

ReactJS - Bootstrap - Buttons

Spring Core | BeanFactoryPostProcessor | Example

Spring Boot 3 + Spring Security 6 + Thymeleaf - Registration and Login Example

File Upload, Download, And Delete - Azure Blob Storage + Spring Boot Example

Custom Exception Handling in Quarkus REST API

ReactJS, Spring Boot JWT Authentication Example

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

Top 5 Java ORM tools - 2024

Java - DES Encryption and Decryption example