JSFiddle - React, Tailwind, and code Playground

HTML

<body>
	<video id="preview" autoplay="true"></video>
	<script>
		(function() {
			var videoConstraints = {
				mandatory: {
			       maxWidth: 320,
			       maxHeight: 240,
			       maxAspectRatio: 4/3,
			       minFrameRate: 2,
			       maxFrameRate: 2
			      },
			      optional: [ ]
			};

			var mediaOptions = {
			    video: videoConstraints,
			    audio: false
			};

			var video = document.getElementById("preview");

			navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

			navigator.getUserMedia(mediaOptions, function (stream) {
			    video.src = window.URL.createObjectURL(stream);
			}, function(err) {
				console.log(err);
			});
		})();	
	</script>
</body>