Last active
June 20, 2019 21:27
-
-
Save admataz/ad78ec6dd88f40be4954527dc2948520 to your computer and use it in GitHub Desktop.
has camera hook
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
const [hasCamera, setHasCamera] = useState(false); | |
useLayoutEffect(() => { | |
navigator.mediaDevices | |
.getUserMedia({ video: true }) | |
.then(hasCamera => setHasCamera(true)) | |
.catch(err => setHasCamera(false)); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment