Skip to content

How to add a background image with this template? #406

Answered by hamzamekk
AmandineScopely asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! @AmandineScopely Thank you for using the template and sharing your question. I'm glad to hear you're learning a lot already!

To address your issue, since you’re using a physical .jpg file located in the ./assets directory, the best way to load it is by using the require function. This is necessary because static assets like images need to be bundled into your project.

Here’s how you can adjust your code:

import React from 'react';
import { ImageBackground, SafeAreaView } from 'react-native';

import { FocusAwareStatusBar, Text, View } from '@/components/ui';

export default function App() {
  return (
    <View className="flex-1">
      <FocusAwareStatusBar />
      <ImageBackground
 …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AmandineScopely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants