import React, {useCallback, useRef, useState} from 'react'; import Webcam from "react-webcam" export interface WebCamCaptureProps { onImageSelected: React.MouseEventHandler } const videoConstraints = { width: 500, height: 500, facingMode: "user" } const WebcamComponent = () => ; const WebcamCapture = (props: WebCamCaptureProps) => { const [image, setImage] = useState(null) const webcamRef = useRef(null); const capture = useCallback(() => { if (webcamRef && webcamRef.current) { const imageSrc = webcamRef.current.getScreenshot(); setImage(imageSrc); } }, [webcamRef]); const useImage = (e: any) => { props.onImageSelected(e) } return (
{image != '' && <>
}
); }; export default WebcamCapture