react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Image] Example issue: ImageView not loading image

Open meetwudi opened this issue 11 years ago • 43 comments

I am playing with the very basic example from Tutorial.

I wrote following code, just exactly what the tutorial did.

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react-native');
var {
  AppRegistry,
  Image,
  StyleSheet,
  Text,
  View,
} = React;

var MOCKED_MOVIES_DATA = [
  {title: 'Title of movie', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}},
];

var Awesome = React.createClass({
  render: function() {
    var movie = MOCKED_MOVIES_DATA[0];
    return (
      <View style={styles.container}>
        <Text>{movie.title}</Text>
        <Text>{movie.year}</Text>
        <Image source={{uri: movie.posters.thumbnail}} 
          style={styles.thumbnail} />
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  thumbnail: {
    width: 53,
    height: 81,
  },
});

AppRegistry.registerComponent('Awesome', () => Awesome);

But it turns out that the ImageView did not load the poster correctly. I changed the backgroundColor of Image to red, and I just got a red rectangle without the poster.

I checked the internet connection. I can access the image from Safari Mobile.

And I don't know if there is any way to debug this app so that I can figure out how to resolve this issue.

Any thoughts?

meetwudi avatar Mar 27 '15 01:03 meetwudi

All of my images loaded from remote are through https protocol. But some images did not load successfully, and this situation just occured on devices with model iPhone 5(may or below, I'm not able to test with iPhone 4/4s) rather than simulators. I found that all images loaded failed are jpg format. React Native version: 0.35 Device: iOS 10.1 iPhone 5

I tried loading these images with native Objective-C code by SDWebImage(a native framework for loading local/web image), these images loaded successfully. It maybe a bug of React Native?

One of these images can not load url: https://cdn.applysquare.net/storage/tmp/qa/thread/DmMz5AkpU.jpg

joint-song avatar Oct 31 '16 08:10 joint-song

I had the same issue using https uri, and specified image size on Android. It's fixed by restart the Android emulator.

GingerBear avatar Aug 25 '17 17:08 GingerBear

any fix for this issue on android?

mopilo avatar Jul 12 '18 09:07 mopilo