0

I'd like to use an iOS launch image as a background image in my React app, but I can't figure out how to reference it. I've tried a few things similar to the following:

<Image source={{uri: "LaunchImage"}} />

But I'm getting this error:

Module `LaunchImage` does not exist in the Haste module map`.

Any ideas?

David Jones
  • 10,117
  • 28
  • 91
  • 139

2 Answers2

1

Try using Image Background tag e.g

  <ImageBackground source={...} style={{width: '100%', height: '100%'}}>
    <Text>Inside</Text>
  </ImageBackground>
Malik Hezret
  • 239
  • 1
  • 8
  • Thanks—I'm getting the same error though: "Module \`LaunchImage\` does not exist in the Haste module map". – David Jones Apr 29 '19 at 04:42
  • I think you need to give correct location of LaunchImage not just "LaunchImage" but source like "../../LaunchImage" in correct location. – Malik Hezret Apr 29 '19 at 04:47
  • The correct location is actually what I'm trying to figure out. See this: https://stackoverflow.com/questions/19410066/ios-7-xcode-5-access-device-launch-images-programmatically – David Jones Apr 29 '19 at 04:54
  • Have you tried using the correct path, mine is in:- import splashscreen from '../Projectname/ios/projectname/Images.xcassets/splashscreen/splashscreen.imageset' which is being imported in index. So make changes to this when you import – G.Kumar Apr 29 '19 at 05:04
  • @G.Kumar I added this line: `import launchImage from "../ios/PackageName/Images.xcassets/LaunchImage.launchimage"`. This is the correct path relative to my component. However, I'm still getting "Module does not exist". – David Jones Apr 29 '19 at 06:29
1

Please include an image in your project src folder and please call image path using require() like this

<Image source={{uri: require('../Images/LaunchImage.png')}} />

here LaunchImage.png is its file name and 'Images' is the folder name

  • Thanks. It looks like its working when I specify the exact image: `source={require("../ios/ProjectName/Images.xcassets/LaunchImage.launchimage/828x1792.png")}`. Is there no way for the exact asset to be auto-selected, as it is when referencing `LaunchImage` in Objective-C or Swift? – David Jones Apr 29 '19 at 06:41