-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<Image> not displaying #1497
Comments
If you produce a test case I'll reopen. The instructions on reporting issues are clear |
I just firstly would like to know if this is expected behavior.. |
Fixed it with the following webpack config (esModule parameter):
|
@lastant, thanks, you saved my day! |
For the life of me, I can not get this to work. I'm on react-native-web 0.14.10 having yesterday generated an app from scratch using
My and I have the Everything builds fine for web ( Everywhere I look online, I see variations of the solution that @lastant gave, in articles and replies to questions but no joy here for me. Has something changed recently in react-native-web that breaks the ability to load static images? I searched all around github hoping to see a react-native-web example app that handles static images, and found nothing, which is surprising to me (I'm pretty decent at searching, heh.) Does this mean that people just generally are not using static images? What's the best practice to share image loading code between mobile and web? I'd rather not have to conditionalize things and start using URIs for the web side, at least not for small images (< 1K). Update: just on the off chance that create-react-native-web-application generator was producing a config problem, I simplified the creation process (and also used javascript instead of typescript). You can see the (failing) project here: |
You don't have to edit the config-overrides for the image to work (in create-react-native-web-application). But you should provide the width/height to the style. It's required in React Native Web. |
Thank you for your prompt reply, @RichardLindhout . Adding the width/height did in fact get the image to appear, and I needed to keep the url-loader in my simple project in order for it to work. You can see that change in this PR Note: when I went back to visit my create-react-native-web-application, I DID still have to leave the url-loader in overrides for the image to appear. |
Hmm, that's strange it should work, what if you use. import AppLogoIcon from '/assets/images/AppLogoIcon.png More here: create-react-native-web-application uses create-react-app in the background |
This saved my day and night too! Thank you very much 💯 |
I had a similar configuration but without |
I am having issues with images as well. Adding esModule: false definitely made some images show up for me now. But I haven't figured out why the icons on the bottom tab navigation container don't show up. Any ideas? `
` |
This has been working... <Image
source={require('./assets/images/reddog.png')}
style={styles.image}
/> If I use
Do I need to configure pathing for image imports? I can actually see the image displayed, after now removing the I'm on React Native 0.64.2 and React Native Web 0.17.1 You can see my example project here: https://github.com/jkoutavas/add-rnw-to-rn-typescript-app. The README covers what I've done to incorporate image loading, specifically the section "A webpack tweak for image loading" |
I use |
Be sure to turn off webpack-dev-server and start it again! It didn't work for me using hot reload, until I've completly restarted webpack server |
Thanks guys; solved my problem |
This had fixed it at one point for me, but when introducing a turborepo setup any assets in the react-native package are now trying to load on the page itself (e.g. a Next GET request for the Directory structure:
Am using these rules, but when it loads that image, it is trying to GET Also need to support default nextjs image loading for images in the
Any ideas? |
I built a project using react-native-web some years ago, and displaying images from assets used to work out of the box:
<Image source={require('../assets/icon-activities.png')} />
would translate to an inlinebackground-image: url("data:image/png;base64,....
. This is very convenient.Now that I updated to the latest version of react-native-web, the images are not displayed at all. I learned about react-native-web-image-loader, but seems it doesn't inline the image data. Is it still possible to inline the image data?
The text was updated successfully, but these errors were encountered: