0

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

1
  • 4
    Try using width and height in style image Commented Nov 3, 2020 at 14:26

1 Answer 1

4

According to the react native documentation:

"Note that you must specify some width and height style attributes."

https://reactnative.dev/docs/imagebackground

Sign up to request clarification or add additional context in comments.

1 Comment

Just update your code for styles.image and add width & height property in addition to other style properties

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.