Created
June 15, 2018 02:03
-
-
Save dceddia/39bc66194a1b2eccdafef876c128a9d8 to your computer and use it in GitHub Desktop.
Importing Camera and rendering based on permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
// add this: | |
import { Camera, Permissions } from 'expo'; | |
export default class App extends React.Component { | |
// initialize state | |
state = { | |
cameraPermission: null | |
}; | |
render() { | |
const { cameraPermission } = this.state; | |
// Render one of 3 things depending on permissions | |
return ( | |
<View style={styles.container}> | |
{cameraPermission === null ? ( | |
<Text>Waiting for permission...</Text> | |
) : cameraPermission === false ? ( | |
<Text>Permission denied</Text> | |
) : ( | |
<Text>yay camera</Text> | |
)} | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment