'ReferencEerror can't find variable:image

import React, {Component} from 'react';
import{ StyleSheet, Text, View, StatusBar } from 'react-native';
export default class Logo extends Component{
render(){
    return(
       <Image source={require('../images/stgi.jpg')} />
        )
}
}
  1. simply just giving the image path it show error how to fix it


Solution 1:[1]

First of all note that if you are using react-native elements make sure you have been import it before using. To import Image try this

import {Image} from 'react-native' ; 

Finally your code should look like this

import React, {Component} from 'react';
import{ StyleSheet, Text, View, StatusBar , Image } from 'react-native';
export default class Logo extends Component{
render(){
    return(
       <Image source={require('../images/stgi.jpg')} />
        )
}
}

Solution 2:[2]

you need to Import Image from react-native.

import{
  Image, 
  StyleSheet, 
  Text, 
  View, 
  StatusBar } from 'react-native';

Solution 3:[3]

You forgot to import the library

import { Image } from "react-native";

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akila Devinda
Solution 2 Mohammed Ashfaq
Solution 3 Khanh Nguyen