9 February 2020

Display Online Image example in react native

  • Create Components folder under src folder
  • Add DisplayOnlineImage.js file and add below Code
import React from "react";
import { ImageText,View } from "react-native";

const DisplayOnlineImage = () => {
  let Image_Http_URL = {
    uri:
      "http://allinoneweb.net/Including/Images/home/logo.png"
  };

  return (
    <View>
      <Text>Display image in react native from online URL example</Text>
      <Image
        style={height: 200width: 350resizeMode: "stretch" }}
        source={Image_Http_URL}
      />
    </View>
  );
};

export default DisplayOnlineImage;
  • Open App.js file and update code as below
import React from 'react';
import {  Text,View,StyleSheet } from 'react-native';
import DisplayOnlineImage from './src/Component/DisplayOnlineImage'

 const  App=()=> {
  return (
    <View style={styles.container}>
      <DisplayOnlineImage/>
    </View>
  );
}
export default App;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    paddingTop:80
  },
});


Output:

No comments:

Post a Comment