Skip to content

Instantly share code, notes, and snippets.

@reime005
Last active December 28, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reime005/f47da0ccb330b0fe098de3eb4c688321 to your computer and use it in GitHub Desktop.
Save reime005/f47da0ccb330b0fe098de3eb4c688321 to your computer and use it in GitHub Desktop.
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