[Image] Retina Assets - Image component does not resolve images with filenames that include '@' symbol
See original GitHub issueIs this a bug report?
Yes, this worked in previous versions.
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v
: 0.46.1node -v
: 8.1.4npm -v
: 5.2.0yarn --version
(if you use Yarn): none
Then, specify:
- Target Platform (e.g. iOS, Android): both
- Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra
- Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): Xcode 8.3.3, Android Studio 2.3, iOS 10.3, Android 7.1.1
Steps to Reproduce
(Write your steps here:)
import React from 'react'
import { Image } from 'react-native'
import logo from '../images/logo@2x.png'
export default function Example () {
return <Image source={logo} />
}
Expected Behavior
Image loaded correctly and displayed.
Actual Behavior
Reproducible Demo
The demo is made from create-react-native-app, eject, and react-native-git-upgrade.
https://github.com/timmywil/react-native-bug-example
I realize the workaround is simple, but I figure a regex got edited somewhere and this is a one-line fix.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:19 (2 by maintainers)
Top Results From Across the Web
Load local images in React.js - Stack Overflow
If I write the image path as src={require('./src/images/logo.png')} in my logo1 variable, it gives the error: Failed to compile. Error in ./src/ ...
Read more >Asset Catalog Format Reference: Image Set Type
Describes the format for the Xcode document used to manage the mapping between named assets and content files.
Read more >How to Make Images Retina-Ready for your Wordpress ...
Learn how to create Retina-ready images for your site here. ... The image resolution doesn't change the amount of data in the image, ......
Read more >Understanding iOS Image Assets - MFractor
A picture still worth a thousand words (no pun intended)... The image above was taken from the article "Real retina vs. non-retina photos"...
Read more >Images in Xamarin.Forms - Microsoft Learn
To use a single image across all apps, the same filename must be used on every platform, and it should be a valid...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s 2018 and I am seeing the exact same issue as @hassanrazakhalid and the others above described. I’m on version
0.51.0
.I have
icon.png
,icon@2x.png
andicon@3x.png
and am using it a laThe dimensions of
icon.png
are12x12px
. The@2x
dimensions are24x24px
,@3x
are36x36px
. I would expect theImage
to render in12x12pt
but it renders in6x6pt
. I’m testing on an iPhone 6 Simulator running iOS 11.2.PixelRatio.get()
gives2
.I believe I followed the instructions on https://facebook.github.io/react-native/docs/image.html exactly, but either there’s a small nuance I’m missing, or this is a bug. But since there’s not a huge outcry it’s hard for me to believe the later.
Did some more digging.
<Image source={require('./my-icon@2px.png')} />
should now be replaced with<Image source={require('./my-icon.png')} />
. React Native/Metro Bundler will pick the correct one based on the device’s screen density.Relevant documentation: https://facebook.github.io/react-native/docs/0.53/images.html
I think it’s definitely related to the move from
react-native/packager
tometro
.