Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/queeniecplusplus/react_cameraapp

askForPermission for using Camera
https://github.com/queeniecplusplus/react_cameraapp

expo-camera react-native usestate

Last synced: about 1 month ago
JSON representation

askForPermission for using Camera

Awesome Lists containing this project

README

        

# React_cameraApp

# expo install

$ expo install expo-camera

# Codebase

import React, { useState, useEffect } from 'react';
import { View, TouchableOpacity } from 'react-native';
import { Camera } from 'expo-camera';

export default function App() {


const [hasPermission, setHasPermission] = useState(null);
const [type, setType] = useState(Camera.Constants.Type.back);

useEffect(() => {

(async () => {
const { status } = await Camera.requestPermissionsAsync();
setHasPermission(status === 'granted');
})();

}, []

);

if (hasPermission === true) {
return ;
}
if (hasPermission === false) {
return No access to camera;
}

return (






{
setType(
type === Camera.Constants.Type.back
? Camera.Constants.Type.front
: Camera.Constants.Type.back
);
}}/>






);


}