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.

React Native Image Defaultsource not working on android

See original GitHub issue

Here is my code. if I load the image as source then is working perfectly. but in defaultSource it is not working.

<Image style={{height:90,resizeMode:"cover", backgroundColor:"red", overflow:"hidden", width:90}} 
    defaultSource={require('../assets/default_profile.png')}
    source={{uri:`${master_api}/images/${num}.jpg`}} />

Here is My packge.json

{
  "name": "truecaller",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.13.3",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/cookies": "^5.0.1",
    "@react-native-community/google-signin": "^5.0.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/picker": "^1.8.1",
    "@react-native-community/slider": "^3.0.3",
    "@react-native-firebase/app": "^10.7.0",
    "@react-native-firebase/auth": "^10.7.0",
    "@react-navigation/bottom-tabs": "^5.11.8",
    "@react-navigation/drawer": "^5.12.2",
    "@react-navigation/material-bottom-tabs": "^5.3.14",
    "@react-navigation/native": "^5.9.3",
    "@react-navigation/stack": "^5.14.3",
    "@twotalltotems/react-native-otp-input": "^1.3.11",
    "faker": "^5.4.0",
    "google-libphonenumber": "^3.2.16",
    "install": "^0.13.0",
    "native-base": "^2.15.2",
    "npm": "^7.5.4",
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-admob": "^2.0.0-beta.6",
    "react-native-admob-native-ads": "^0.3.9",
    "react-native-android-notification-listener": "^2.0.0",
    "react-native-android-recyclerview": "^1.0.2",
    "react-native-animatable": "^1.3.3",
    "react-native-awesome-pin": "^1.3.1",
    "react-native-call-detection": "^1.9.0",
    "react-native-contacts": "^6.0.4",
    "react-native-fbsdk": "^3.0.0",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-image-crop-picker": "^0.36.0",
    "react-native-intent-launcher": "^0.2.1",
    "react-native-largelist": "^1.2.12",
    "react-native-largelist-v3": "^3.0.15",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-modal": "^11.6.1",
    "react-native-neomorph-shadows": "^1.1.2",
    "react-native-otp-textinput": "0.0.8",
    "react-native-paper": "^4.7.1",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.15.2",
    "react-native-shared-element": "^0.7.0",
    "react-native-spring-scrollview": "^2.0.23",
    "react-native-svg": "^12.1.0",
    "react-native-vector-icons": "^8.0.0",
    "react-navigation-shared-element": "^5.0.0-alpha1",
    "realm": "^10.2.0",
    "reanimated-bottom-sheet": "^1.0.0-alpha.22",
    "recyclerlistview": "^3.0.5"
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.18.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
1mehdifarajicommented, Oct 25, 2021

It doen’t work iOS either

3reactions
dulmandakhcommented, Apr 2, 2021

Please read documentation carefully, and you’ll find below note.

Note: On Android, the default source prop is ignored on debug builds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native: How to set Image defaultSource on Android
I have tried using @Ravi Raj's answer but seems not related to failure on loading image. Beside the answer will make the image...
Read more >
Image - React Native
A React component for displaying different types of images, including network ... GIF and WebP are not supported by default on Android.
Read more >
How to set Image defaultSource on Android-React Native
Coding example for the question react native: How to set Image defaultSource on Android-React Native.
Read more >
Implement defaultSource for Image on Android - React Native
It allows the image file to be downloaded in the background while showing the placeholder image. Once the image has been downloaded, it...
Read more >
Image – React Native | A framework for building ... - Deco IDE
iosdefaultSource {uri: string} # ... A static image to display while downloading the final image off the network. iosonError function #.
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