Image.resolveAssetSource not supported on web.

See original GitHub issue

🐛 Bug Report

Summary of Issue

When I run Image.resolveAssetSource on Expo web I get an error that the function doesn’t exist.

Environment - output of expo diagnostics & the platform(s) you’re targeting

Targeting Expo web, SDK 39.

Reproducible Demo

Copy in the following code

import { Image } from 'react-native'
Image.resolveAssetSource({uri: 'foobar'})

Steps to Reproduce

Run the above code.

Expected Behavior vs Actual Behavior

Expect the code to run. Instead I receive the following error.

Unhandled Rejection (TypeError): react_native_web_dist_exports_Image__WEBPACK_IMPORTED_MODULE_6__.default.resolveAssetSource is not a function

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
greenimpalacommented, Feb 3, 2021

If your asset source is a string file path then you can polyfill with

if (Platform.OS === "web"
    Image.resolveAssetSource =  source => { uri: source }   
}
1reaction
AlastairTaftcommented, Oct 20, 2020

Thanks for the link, I ended up writing my own polyfill, but good to know cheers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Image.resolveAssetSource() is not returning the height ...
When I use it for static images(require()) it works fine and return the height and width property along with other useful properties, but...
Read more >
How to obtain a URI for an image asset in React Native (With ...
React Native's official Image Component provides us with a method called resolveAssetSource(). This method takes a “number” (related to what I've mentioned ...
Read more >
Example of Image.resolveAssetSource() in React Native
Image.resolveAssetSource() function is used to get local resource assets image folder image width and height. It return us 4 type of values ...
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 >
Image · React Native 中文
DOCTYPE html> <meta charset="utf-8"> <title>React Native Web ... When building your own native code, GIF and WebP are not supported by default on...
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