Reputation: 494
I want to set an background image to my app. When I run expo start
the image dosen't show.
this its my component:
import React from "react";
import { StyleSheet, Text, View, ImageBackground } from "react-native";
import { Asset } from "expo-asset";
export default function App() {
return (
<View style={styles.container}>
<ImageBackground
source={{
uri: Asset.fromModule(require("./images/background.png")).uri,
}}
style={styles.image}
></ImageBackground>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
image: {
flex: 1,
resizeMode: "cover",
justifyContent: "center",
},
});
what I missed? I appreciate any help
Upvotes: 0
Views: 3202
Reputation: 259
According to the react native documentation:
"Note that you must specify some width and height style attributes."
https://reactnative.dev/docs/imagebackground
Upvotes: 3