React-native: Image `defaultSource` not loading

Created on 13 Sep 2016  路  17Comments  路  Source: facebook/react-native

Issue Description

Image defaultSource not loading. It was loading in the previous version but now it's not loading.

Steps to Reproduce / Code Snippets

<Image source={{uri:${Constants.BASE_URL}${data.icon}}} defaultSource={require('image!noimage')} style={styles.detailImage}/>

Expected Results

should show default image

Additional Information

  • React Native version:0.33
  • Platform(s) (iOS, Android, or both?): iOS
  • Operating System (macOS, Linux, or Windows?): macOS
Locked

Most helpful comment

For mine it started worked once I set the backgroundColor for Image.

<Image resizeMode="cover"
    defaultSource={require('../assets/placeholder-image.png')}
    source={{ uri: rowData.thumbnail }} 
    style={{ backgroundColor: '#f1eff0', height: 150, width: 150 }} />

All 17 comments

Does the defaultSource file load if you use it in the source attribute?

yes, i already tried it

It works well on the master branch.
Could you post an rnplay url to reproduce it?

Isn't rnplay quite outdated, speaking of the RN Version?

@leeight
on 0.33 default Image is not loading. Is master on 0.33 or 0.34 rc ?

I noticed that other props must be set in order for the defaultSource to work, ex: backgroundColor, margin...

I'm getting the same issue. Note that defaultSource DOES load correctly if you remove the source attribute. That's not really acceptable though. @ajoshdee which props exactly? is it consistent?

Having the same issue with RN 0.39.

@JulianCurrie, when I set 'backgroundColor: white', defaultSource is loading.

I've met the same problem in RN 0.41
But I found that if I set an 'onLoad' prop with the empty function (()=>null) to the Image tag, can make it work.

@CDog34 can you post an example? I have the same issue and can't seem to fix it.

I've noticed the same behavior with RN 0.43.3. In some cases defaultSource doesn't show while in other cases it works as expected. As a workaround I use blurRadius={0} on the Image to properly show the default source.

Assumption: Problem could be related to the size of image. In my case defaultSource image is kinda low (width 40px). It shows correctly when shown as a thumbnail of small size but it doesn't show when rendered to a larger size (almost full device screen).

Just hit the same issue. borderRadius={1} was enough to fix for me.

For mine it started worked once I set the backgroundColor for Image.

<Image resizeMode="cover"
    defaultSource={require('../assets/placeholder-image.png')}
    source={{ uri: rowData.thumbnail }} 
    style={{ backgroundColor: '#f1eff0', height: 150, width: 150 }} />

It seems if you set any prop, it works.

However, I am experiencing a different issue. I have the image in a renderRow() of a ListView. When I delete one row, let's say the first, the source image goes on top of the second image row.

It is working on iOS for me but looks like the 'defaultSource' is not supported on Android.

@rohitgoyal Yes, it is iOS only according to the official documents.

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

Was this page helpful?
0 / 5 - 0 ratings