How to add a background image with this template? #406
-
Hi! Thanks a lot for your template. I am a beginner React Native developer and am already learning a lot! I would like my index page to have a background image. How could I add this? I currently have my image in the I've read this documentation but I don't have any URI for my file, I have a physical .jpg image. Also, I was using the component from react-native before migrating to this template. What is the best approach? This is my old code:
Also, what does the component doing? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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:
Why require? |
Beta Was this translation helpful? Give feedback.
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: