I’m running a super simple app where I want an Image
to be centered within its container View
, using resizeMode='center'
.
import * as React from 'react';
import { View, Image } from 'react-native';
export default function App() {
return (
<View style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<View style={{
height: 30,
width: 30,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'lightgrey',
}}>
<Image
resizeMode='center'
styles={{
width: '100%',
height: '100%',
}}
source={require('./assets/hexagon2x.png')} />
</View>
</View>
);
}
Also at this snack.
When I run the unpublished project on my device (iPhone SE 2nd Gen) or on a simulator, I get the desired behavior, with the Image
centered in the middle of the containing View
:
However, when I run expo publish
on this exact project and open the published app, the Image
is no longer contained within the View
:
Any ideas what might be going on here?