question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot load local images in 0.63.4 in iOS simulator

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

After adding image to source tree, when using code like <Image source={ require('./path_to_image.png') } /> the image is not rendered and no error is shown. If I use a URI or icon, it renders.

React Native version:

Run react-native info in your terminal and copy the results here. System: OS: macOS 11.1 CPU: (8) x64 Intel® Core™ i7-1068NG7 CPU @ 2.30GHz Memory: 500.91 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.5.0 - /usr/local/bin/node Yarn: 1.22.5 - ~.yarn/bin/yarn npm: 6.14.9 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.0 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 12.3/12C33 - /usr/bin/xcodebuild Languages: Java: Not Found Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps To Reproduce

See above.

Expected Results

Image renders

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
plniicommented, Jan 27, 2021

I tested the above approach it seems to have worked. It turned out the defect I was experiencing was with React Native Elements, which use the same Image tag. I see they fixed the defect here: https://github.com/react-native-elements/react-native-elements/pull/2717

0reactions
mechazodcommented, Jan 25, 2021

@plnii I see, you can try this file structure.

.
|--src
|---App.js
|---images
|----test1.jpg
|----test2.png
|----...
index.js

Let say I’m inside App.js, then I want to load those two or more images

Access local files via import
import Image1 from './images/test1.jpg';

<Image source={Image1} />

Access local files via require

<Image source={require('./images/test2.png')} />

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot load local images in 0.63.4 in iOS simulator - GitHub
A framework for building native applications using React - Cannot load local images in 0.63.4 in iOS simulator · facebook/react-native@e3a05c9.
Read more >
React native 0.63.4 ios 14 no static images - Stack Overflow
I try to build a release with Xcode 12.4 (12D4e) and react native 0.63.4 and local images are not shown but url images...
Read more >
Simulator fails to import data - X… | Apple Developer Forums
So if I drag and drop a simple jpg photo which normally would appear in the Photos App I get the following error:...
Read more >
Issue rendering local static image in iOS only (React Native)
Then try to set justifyContent: center and alignItems: center to make sure the image is not being hidden for some reason. You might...
Read more >
Fix Images Not loading In iOS 14 — React Native | by jQN
Today I decided to finally upgrade Xcode to version 12.0.1 which means the simulators were also upgraded to iOS version 14. The project...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found