Skip to content
Advertisement

Can’t show Image in React Native

I’m using react-native 0.28.0

I’m trying to show an image on iPhone simulator according to this tutorial: Introduction to React Native: Building iOS Apps with JavaScript | Appcoda

var styles = StyleSheet.create({
image: {
    width: 107,
    height: 165,
    padding: 10
  }
}

var imageURI = 'http://books.google.com/books/content?id=PCDengEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api'

Then in the render() function, I add this:

<Image style={styles.image} source={{uri:imageURI}} />

The space allocated for the image is there, but the image is not shown.

Advertisement

Answer

In addition to Jonathan Stellwag’s answer, the 1st solution only works if the URI is using https, or by setting the App Transport Security.

See Can’t show Image by URI in React Native iOS Simulator

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement