const i = new Image(); does not work on react-native iOS and Android

I am having the following error in react-native:

[Unhandled promise rejection: ReferenceError: Can't find variable: Image]
* src/utils/b64ToBlob.js:45:56 in Promise$argument_0

And this is the function where it fail in b64ToBlog.js:

export const getImageDimensions = (file) => new Promise((resolved) => {
  const i = new Image();
  i.onload = () => resolved(i);
  i.src = file;

On both iOS and Android, it fails on const i = new Image();:

How can I provide Image or get an image dimensions from an URL or how can I provide Image in react-native?

I believe this is how you’re supposed to do it:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.