9 February 2020

Display local image example in react native

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

const DisplayLocalImage = () => {
  return (
    <View>
      <Text>Display Local folder image in react native example</Text>
      <Image
        style={height: 200width: 350resizeMode: "stretch" }}
        source={require("../Images/logo.png")}
      />
    </View>
  );
};

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

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

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


Output:

No comments:

Post a Comment