1

Camera doesn't turn off when change Tab/View

render() {
  const { hasCameraPermission } = this.state;
  if (hasCameraPermission === null) {
    return <View><Button
         onPress={() => this.showCamera()}
           title="Show Camera"
          />
         </View>;
  } else if (hasCameraPermission === false) {
    return <Text>No access to camera</Text>;
  } else {
    return (
      <View>
        <Camera>
        </Camera>
      </View>
    );
  }
}

In the view i have the button that can display the Camera. But once, the camera if turn on. When i change tab (tab nvigation) and come back to the view, i doesn't have the button, but a black screen. it seems the camera is not turn off.

Thank you

csu
  • 385
  • 1
  • 7
  • 20

1 Answers1

0

Create a specific component for displaying caméra.

csu
  • 385
  • 1
  • 7
  • 20
  • 1
    Sorry, could you elaborate on what you mean by this? I am having the same issues – Ken May 03 '21 at 16:13
  • Have tried doing this but nothing works. Looked at the Code for Expo BarCodeScanner and it seems like they never call the closeCamera or closePreview function from anywhere. It looks like it should be fixed from the Expo BarCodeScanner side – Sudhanshu Bhagwat Jun 10 '22 at 11:52