Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React Native With Expo: Web Browser not rendering images

$
0
0

I am building an app with React Native. I have a <Image /> react native component that renders on android but doesn't seem to render on the browser. When inspecting the element, the browser has the image element with the size of 0x0.

I am using the expo-cli and created a fresh project with the following code (stripped out version of my code) to isolate the issue. It works for android but doesn't show an image for web.

Also, I tried it using https://snack.expo.io and it works for web there.

Is there something I am missing here?

Isolated Code:

import React from 'react';import { Text, Image, View, StyleSheet } from 'react-native';const source = require("./assets/icon.png");export default function App() {  return (<View style={styles.container}><Text>test: </Text><Image style={styles.image} source={source} /></View>  );}const styles = StyleSheet.create({  container: {    display: "flex",    alignItems: "center",    flexDirection: "row",    height: "5%",  },  image: {    resizeMode: "contain",    maxHeight: "100%",    flexShrink: 2,    flexGrow: 0,  }});

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>