import { NavigationContainer } from '@react-navigation/native' import React, { useEffect, useState } from 'react' import { createNativeStackNavigator } from '@react-navigation/native-stack' import { PermissionsPage } from './PermissionsPage' import { MediaPage } from './MediaPage' import { CameraPage } from './CameraPage' import type { Routes } from './Routes' import { Camera, CameraPermissionStatus } from 'react-native-vision-camera' import { GestureHandlerRootView } from 'react-native-gesture-handler' import { StyleSheet } from 'react-native' const Stack = createNativeStackNavigator() export function App(): React.ReactElement | null { const [cameraPermission, setCameraPermission] = useState() const [microphonePermission, setMicrophonePermission] = useState() useEffect(() => { Camera.getCameraPermissionStatus().then(setCameraPermission) Camera.getMicrophonePermissionStatus().then(setMicrophonePermission) }, []) console.log(`Re-rendering Navigator. Camera: ${cameraPermission} | Microphone: ${microphonePermission}`) if (cameraPermission == null || microphonePermission == null) { // still loading return null } const showPermissionsPage = cameraPermission !== 'granted' || microphonePermission === 'not-determined' return ( ) } const styles = StyleSheet.create({ root: { flex: 1, }, })