react-native-web: not displaying
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 inline background-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?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (3 by maintainers)
Fixed it with the following webpack config (esModule parameter):
If you produce a test case I’ll reopen. The instructions on reporting issues are clear
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?
`
`
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.
Don’t do any thing just dont use ‘require’ here use <Image source={logo} accessibilityLabel="React logo" resizeMode="contain" style={styles.logo} /> import logo from ‘./logo.png’;
I had a similar configuration but without
esModule: false
, adding that line did the trickThank 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.
I just firstly would like to know if this is expected behavior…