FG
📱 Mobile & Cross-Platform

Image cannot show image in iOS 14

Freshabout 19 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

Image cannot show image in iOS 14, but can show location, like: <Image source={ require('./images/add_scan_images.png') } /> Environment: Xcode Version 12.0 beta (12A6159) Simulator: IPhone SE - 2nd generation - 14.0 "react": "16.11.0", "react-native": "0.62.2"

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix Image Rendering Issue in iOS 14 for React Native

Medium Risk

The issue arises due to changes in how images are handled in iOS 14, particularly with the asset bundling and resource loading in React Native. The require statement may not resolve correctly due to caching or path issues in the new environment.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check Image Path

    Ensure that the image path is correct and that the image file exists in the specified directory. Sometimes, path issues can prevent the image from loading.

    javascript
    const imageSource = require('./images/add_scan_images.png');
  2. 2

    Clear Cache

    Clear the React Native packager cache to ensure that any stale assets are removed. This can be done by running the following command in your project directory.

    bash
    react-native start --reset-cache
  3. 3

    Update React Native

    Consider updating React Native to a more recent version that may have fixed compatibility issues with iOS 14. Check the changelog for any relevant fixes.

    bash
    npm install react-native@latest
  4. 4

    Use Image Component Properly

    Ensure that the Image component is used correctly. If the image is not rendering, try using the `source` prop with an object that includes the `uri` property as a fallback.

    javascript
    <Image source={{ uri: 'path/to/image/add_scan_images.png' }} />
  5. 5

    Test on Physical Device

    If the issue persists in the simulator, test the application on a physical device running iOS 14 to ensure that the problem is not simulator-specific.

    bash
    npx react-native run-ios

Validation

To confirm the fix worked, run the application and check if the image renders correctly on both the simulator and a physical device. Verify that there are no errors in the console related to image loading.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

react-nativemobileiosandroidplatform:-iosresolution:-lockedcomponent:-imageneeds:-author-feedback