question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image component with local uri source (file://) does not render initially

See original GitHub issue

Image components with local uri sources (file://) do not render initially. When a re-render of the component tree happens, the images get rendered.

Environment

Environment: OS: macOS High Sierra 10.13.1 Node: 8.9.1 Yarn: 1.3.2 npm: 5.5.1 Watchman: 4.9.0 Xcode: 9.1 (9B55) Android Studio: 3.0.1

Packages: (wanted => installed) react-native: 0.51.0 (@sraka1 reports this is still an issue in 0.58.4) react: 16.0.0

Target Platform: Android (5.0.0)

Steps to Reproduce

const image = {uri: 'http://my.bamps.online/cfs/files/images/D8Xg27puAiqjvKetD?store=normal'}
// image2 is cached version of image by react-native-cached-image
const image2 = {uri: 'file:///data/data/com.testcachedimage/cache/imagesCacheDir/my_bamps_online_e6d51c26611343fb5e8c3e493674423c3d3f3943/38baef384cbb5bcc5f6138ca0653884561f85fde.jpg'}
export default class App extends Component<{}> {
  render() {
    return (
      <View style={{backgroundColor:'#777'}}>
        <Image source={image2} style={{width: 100, height: 100}}/>
        <Image source={image2} style={{width: 300, height: 100}}/>
        <ImageBackground source={image2} style={{width: 100, height: 100}}/>
        <ImageBackground source={image2} style={{width: 300, height: 100}}/>
        <Image source={image} style={{width: 100, height: 100}}/>
        <Image source={image} style={{width: 300, height: 100}}/>
      </View>
    );
  }
}

Actual Behavior

2017-12-06_15-05-16

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:30 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
KonstantinKolodnitskycommented, Jan 5, 2019

My issue was in path. react-native-fs returns path like /storage/emulated/0/Android/data/com.blah/blah.jpeg but Image component requires it to be file:///storage/emulated/0/Android/data/com.blah/blah.jpeg

2reactions
hramoscommented, Feb 12, 2019

Re-opened and made some edits. @sraka1 let me know if you have additional suggestions to get the description of the issue up to date.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't show Image in React Native - Stack Overflow
See Can't show Image by URI in React Native iOS Simulator ... IOS 14.x it is an issue being generated that image is...
Read more >
How to obtain a URI for an image asset in React Native (With ...
Using require() has a couple of caveats. First, it's CommonJS and we're working on the browser-side of things, where it doesn't really belong, ......
Read more >
Image · React Native - API Manual
A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, ...
Read more >
Using the image tag in React - Dave Ceddia
When you img in a React component, the the src prop needs to be point at something that the server can serve. Don't...
Read more >
Images - React Native
Static Image Resources​ · Same system on Android and iOS. · Images live in the same folder as your JavaScript code. · No...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found