Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/queeniecplusplus/react_cameraapp
- Owner: QueenieCplusplus
- Created: 2020-07-20T09:58:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T22:05:16.000Z (almost 2 years ago)
- Last Synced: 2023-03-04T03:12:03.129Z (almost 2 years ago)
- Topics: expo-camera, react-native, usestate
- Language: JavaScript
- Homepage: https://github.com/QueenieCplusplus/QuickGoThru/blob/master/README.md#react--react-native
- Size: 2.35 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React_cameraApp
# expo install
$ expo install expo-camera
# Codebaseimport 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
);
}}/>
);
}