expo-camera not working.

I have tried following the documentation, but I’m unable to get it work. I have no other screens mounted which uses the camera.

  • hasPermission returns true
  • onCameraReady never executes.

It’s just a black background that fills the screen with no preview.

import React, { useState, useEffect, useCallback, ReactElement } from "react";
import { View } from "react-native";
import styles from "./styles";
import { Camera } from "expo-camera";

const CameraScreen: React.FC = (): ReactElement => {
  const [hasPermission, setPermission] = useState<boolean>(false);
  const [cameraRef, setCameraRef] = useState<any>();

  const snap = useCallback(async (): Promise<void> => {
    const picture = await cameraRef.takePictureAsync();
    console.log(picture);
  }, [cameraRef]);

  useEffect(() => {
    (async () => {
      const { status } = await Camera.requestPermissionsAsync();
      setPermission(status === "granted");
    })();
  }, []);

  return (
    <View style={{ flex: 1 }}>
      {hasPermission && (
        <Camera
          ref={(e) => setCameraRef(e)}
          onCameraReady={(e) => console.log(e)}
          style={{ flex: 1 }}
        ></Camera>
      )}
    </View>
  );
};

export default CameraScreen;

  1. SDK Version: 39
  2. Platforms: (Android)