ReferencEerror can't find variable:image

Viewed 12956
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
3 Answers

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

you need to Import Image from react-native.

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

You forgot to import the library

import { Image } from "react-native";

Related