0

How come when I use a network image,

<View style={{flex: 1, alignItems: 'stretch'}}>
          <Image
           style={{flex: 1}}
           source={{uri: 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'}} />
</View>

it fills the page: Google logo stretched across screen

but when I use require() for a static image:

<View style={{flex: 1, alignItems: 'stretch'}}>
 <Image
  style={{flex: 1}}
  source={require('./googlelogo.png')} />
</View>

it doesn't? enter image description here

Running react-native 0.37.0. This code was added straight into a freshly react-native init-ed project, no 3rd party libraries or anything.

AnthonyJoeseph
  • 223
  • 3
  • 10

1 Answers1

1

Probably you were having the same issue as this.

Try setting the Image's width to null:

<Image
  style={{flex: 1, width: null}}
  source={require('./googlelogo.png')} />
Community
  • 1
  • 1
max23_
  • 6,531
  • 4
  • 22
  • 36