Dhaval
Dhaval

Reputation: 978

Why in react native Image is not displaying in simulator?

I am new in react native and want to display images, i setup project with expo and try following code for displaying image i do some research but i think code is right, i don't know why it's not displaying in simulator, Do anyone have any idea.

code:

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

const ImageDetail = (props) => {
    return (
        <View>
            <Image source={require('./beach.jpg')} />
            <Text>{props.title}</Text>
        </View>
    )
};

const style = StyleSheet.create({

});

export default ImageDetail;

I have image in same folder where file is.

Upvotes: 0

Views: 571

Answers (1)

Guruparan Giritharan
Guruparan Giritharan

Reputation: 16334

Provide a style with height and width for the Image, without that the image component wont display the image.

<Image style={{height:100,width:100}} source={require('./beach.jpg')} />

Upvotes: 1

Related Questions