Last active
December 28, 2020 14:20
-
-
Save reime005/f47da0ccb330b0fe098de3eb4c688321 to your computer and use it in GitHub Desktop.
This file contains 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 * as React from 'react'; | |
import { View, TouchableOpacity } from 'react-native'; | |
import { RNCamera } from 'react-native-camera'; | |
import { useCamera } from 'react-native-camera-hooks'; | |
export const ExampleComponent = ({ initialProps }) => { | |
const [ | |
{ cameraRef, type, isRecording }, | |
{ recordVideo, setIsRecording }, | |
] = useCamera(initialProps); | |
return ( | |
<View style={{ flex: 1 }}> | |
<RNCamera ref={cameraRef} type={type} style={{ flex: 1 }} /> | |
{!isRecording && ( | |
<TouchableOpacity | |
onPress={async () => { | |
try { | |
setIsRecording(true); | |
const data = await recordVideo(); | |
} finally { | |
setIsRecording(false); | |
} | |
}} | |
style={{ width: '100%', height: 45 }} | |
/> | |
)} | |
</View> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment