Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6215

Unhandled promise rejection: TypeError: null is not an object (evaluating camera.pictureSize)

$
0
0

I am creating a react-native app to use the expo-camera module.

So I declared a camera variable as

let camera: any = null;

I am passing a reference to this from the return as:

<Camera style = {{flex: 1, opacity: camOpacity}}          type = {state.type}          ratio = "2:1"          ref = {async (ref) => (camera = ref)}>

But when I run the app, it starts normally but on trying to take a picture it gives the error:

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'camera.pictureSize')]

This error is occuring from :

console.log(camera.pictureSize);

But it is also happening at:

console.log(" --> Taking image");    const opts = {       skipProcessing: true,       exif: false,       quality: 0    };    let photo = await camera.takePictureAsync(opts);

from the camera.takePictureAsync(opts) part when I am commenting out the console.log(camera.pictureSize);

For some reason the reference isn't getting detected maybe.

My package.json is:

"dependencies": {"expo": "~39.0.2","expo-2d-context": "0.0.2","expo-asset": "~8.2.0","expo-camera": "~9.0.0","expo-gl": "~9.1.1","expo-image-manipulator": "~8.3.0","expo-permissions": "~9.3.0","react": "16.13.1","react-dom": "16.13.1","react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz","react-native-web": "~0.13.12","react-native-screens": "~2.10.1","react-native-svg": "~12.1.0","mem": "^8.0.0","@unimodules/core": "~5.5.0"  }

I read there were some such errors in the current expo-camera release, but even if I downgrade the packages and dependencies it is still being persistent.

Any help would be really appreciated.


Viewing all articles
Browse latest Browse all 6215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>