Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferencEerror can't find variable:image

Tags:

react-native

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
like image 881
Aoudesh01 Avatar asked Aug 28 '18 01:08

Aoudesh01


2 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')} />
        )
}
}
like image 164
Akila Devinda Avatar answered Oct 31 '22 20:10

Akila Devinda


you need to Import Image from react-native.

import{
  Image, 
  StyleSheet, 
  Text, 
  View, 
  StatusBar } from 'react-native';
like image 7
Mohammed Ashfaq Avatar answered Oct 31 '22 20:10

Mohammed Ashfaq